Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strange error in compiling small c++ code [closed]

Tags:

c++

I tried to compile the following code, but it fails:

#include <iostream>

    int main(){
    double conveter, temp=25;

    conveter = (temp – 32.0) * 5.0/9.0;
    std::cout<<conveter;
        return 0;
    }

with this error:

error C2146: syntax error : missing ')' before identifier '–'

Any advise please?

like image 866
Aan Avatar asked Jun 25 '26 12:06

Aan


2 Answers

Wrong minus sign, type the minus sign again, then it works perfectly. Unicode...

You -> me -

like image 189
Blacktempel Avatar answered Jun 28 '26 03:06

Blacktempel


You've somehow ended up with a Unicode "en dash" character instead of an ASCII -.

Make sure you're using a plain text editor not a word processor; delete and retype the dash; and be careful where you copy and paste code from.

like image 25
Mike Seymour Avatar answered Jun 28 '26 03:06

Mike Seymour



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!