Compiler errors

Discussion in 'C++' started by deanfamily11, Sep 5, 2005.

  1. deanfamily11

    deanfamily11 Guest

    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;

    }
     
    deanfamily11, Sep 5, 2005
    #1
    1. Advertising

  2. deanfamily11 wrote:
    > 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

    > }
    >
    >
     
    John Harrison, Sep 5, 2005
    #2
    1. Advertising

  3. deanfamily11

    deanfamily11 Guest

    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.

    "John Harrison" <> wrote in message
    news:MJ1Te.5277$...
    > deanfamily11 wrote:
    >> 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
    >
    >> }
     
    deanfamily11, Sep 5, 2005
    #3
  4. deanfamily11 wrote:
    > 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
     
    John Harrison, Sep 5, 2005
    #4
  5. deanfamily11

    pk_prashant Guest

    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;'





    deanfamily11 wrote:
    > 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;
    >
    > }
     
    pk_prashant, Sep 6, 2005
    #5
  6. pk_prashant wrote:
    > 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.
     
    =?ISO-8859-1?Q?Stefan_N=E4we?=, Sep 6, 2005
    #6
  7. deanfamily11

    Howard Guest

    "deanfamily11" <> wrote in message
    news:sF1Te.16296$Sx4.12121@trnddc06...
    > 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
     
    Howard, Sep 6, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,031
    Mark Goldin
    Jan 17, 2004
  2. SenthilVel
    Replies:
    0
    Views:
    977
    SenthilVel
    Jun 7, 2006
  3. George1776

    Out-of-memory errors and caching errors.

    George1776, Aug 28, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,364
    George1776
    Sep 14, 2006
  4. Lance Wynn
    Replies:
    1
    Views:
    1,917
    Lance Wynn
    Feb 3, 2008
  5. yawnmoth
    Replies:
    97
    Views:
    4,805
    Bent C Dalager
    Feb 27, 2009
Loading...

Share This Page