I have a simple c++ code like this:
#include <iostream>
#include <string>
using namespace std;
int main() {
int n , a , b ;
cin >> n >> a >> b ;
//This two lines are exactly same!!!!
cout << n - max(a + 1, n - b) + 1 << endl ;
//cout << n - max(a + 1, n - b) + 1 << endl ;
}
In this code I have two line that are exactly same but when I compile the exact above code I get my result with any input for example(5,2,3) but when I uncomment the second cout
and comment the first one with all previous condition the code doesn't compile(GNU 4.8.2) and get this error:
sample.cpp:8:5: error: stray ‘\342’ in program
cout << n - max(a + 1, n - b) + 1 << endl ;
^
sample.cpp:8:5: error: stray ‘\200’ in program
sample.cpp:8:5: error: stray ‘\211’ in program
sample.cpp:8:5: error: stray ‘\342’ in program
sample.cpp:8:5: error: stray ‘\200’ in program
sample.cpp:8:5: error: stray ‘\211’ in program
sample.cpp:8:5: error: stray ‘\342’ in program
sample.cpp:8:5: error: stray ‘\200’ in program
sample.cpp:8:5: error: stray ‘\211’ in program
sample.cpp:8:5: error: stray ‘\342’ in program
sample.cpp:8:5: error: stray ‘\200’ in program
I try with Microsoft Visual C++ 2010 compiler and I got the same result but with different error:
program.cpp
program.cpp(9) : error C2065: 'n¢?%' : undeclared identifier
program.cpp(9) : error C2065: 'a¢?%' : undeclared identifier
program.cpp(9) : error C2065: '¢?%1' : undeclared identifier
program.cpp(9) : error C2065: '¢?%n¢?%' : undeclared identifier
program.cpp(9) : error C2065: '¢?%b' : undeclared identifier
program.cpp(9) : error C2146: syntax error : missing ';' before identifier '¢?%'
program.cpp(9) : error C3861: '¢?%max': identifier not found
program.cpp(9) : error C2065: '¢?%' : undeclared identifier
program.cpp(9) : error C2065: '¢?%1' : undeclared identifier
I can't understand both cout
are exactly same but first one work properly and second one doesn't why is this a compiler bug??