Compiler errors

D

deanfamily11

When I run the following code through my compiler, I get C2065 and C2145
errors. Can someone help?


#include <iostream>
using namespace std;


int main ()
{
//declare variables
double dblin;
int intout;

//requesting a number
cout << "Enter a decimal number to round: ";

//user input
cin >> dblin;
cout << endl;

//round the number
intout = dblin;

//output the rounded number
cout << "The number rounded is ";
cout << intout;
cout << endl;

round 0;

}
 
J

John Harrison

deanfamily11 said:
When I run the following code through my compiler, I get C2065 and C2145
errors. Can someone help?

See below.
#include <iostream>
using namespace std;


int main ()
{
//declare variables
double dblin;
int intout;

//requesting a number
cout << "Enter a decimal number to round: ";

//user input
cin >> dblin;
cout << endl;

//round the number
intout = dblin;

//output the rounded number
cout << "The number rounded is ";
cout << intout;
cout << endl;

round 0;

Should be

return 0;

Try reading the error messages next time, I got

error C2065: 'round' : undeclared identifier

Seems pretty clear to me.

john
 
D

deanfamily11

I had read that, but didn't think to look down at the end. It's been awhile
since I did any C++ coding. Thanks for the help.
 
J

John Harrison

deanfamily11 said:
I had read that, but didn't think to look down at the end. It's been awhile
since I did any C++ coding. Thanks for the help.

If you double click on the error message it takes you to the line that
caused the error.

john
 
P

pk_prashant

To correct this error,

either, replace the 'round 0;' to 'return 0;' or,
change the 'int main ()' to 'void main()' and remove the 'return 0;'
 
?

=?ISO-8859-1?Q?Stefan_N=E4we?=

pk_prashant said:
To correct this error,

either, replace the 'round 0;' to 'return 0;' or,
change the 'int main ()' to 'void main()' and remove the 'return 0;'

WRONG!

it's ALWAYS 'int main()' or 'int main(int argc, char* argv[])' and
NEVER EVER 'void main()'

So, the fix would be to change 'round 0;' to 'return 0;' or remove that line
completely.


/S.
 
H

Howard

deanfamily11 said:
When I run the following code through my compiler, I get C2065 and C2145
errors. Can someone help?

Please don't assume that, because your compiler reports those error codes,
everyone else's will also. Compilers differ on how they report errors.
There are no "standard" error codes. Indeed, there is no reason to even
assume that any "error code" at all is reported. You may only see text as
output from the compile attempt, such as "Syntax error, line16: ';' expected
here", or something similar. To most of us, "C2065" has no meaning
whatsoever. It's the text that tells us what is wrong, not some obscure
code.

Next time, let us know the text associated with the error code, not the
error code itself.

(Also, please place your replies _after_ the text to which you are replying,
not at the top. That's the standard for usenet postings.)

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top