Code: #pragma once #include <iostream> using namespace std; int main() { int num,cout=0; cout <<"Enter the number:"; //here is the error cin>>num; bool done=true; while(done) { if (num>=10) { num=num/10; cout++; } else { cout++; done=false; } } printf ("%d",cout); // its working fine system("pause"); return 0; } Error: Can anyone tell me why this error is occuring, it's point at the "cout" statement. as much as cout i m using errors are increasing. Error 1 error C2297: '<<' : illegal, right operand has type 'const char [18]' Warning 2 warning C4552: '<<' : operator has no effect; expected operator with side-effect
You've redefined cout as an int and set it to zero on the previous line. The error is correct because you can't shift left an integer by a char array number of bits - this is meaningless. You can only shift an integer left by another integer.