Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Error here (http://www.go4expert.com/forums/error-here-t15433/)

Carlos 7Dec2008 22:27

Error here
 
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

xpi0t0s 7Dec2008 23:19

Re: Error here
 
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.


All times are GMT +5.5. The time now is 07:08.