Error here

Carlos's Avatar, Join Date: Dec 2008
Contributor
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

Last edited by shabbir; 7Dec2008 at 22:41.. Reason: Code block
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.