Thread: error #2605

  1. #1
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25

    error #2605

    hey everyone my name is alyssa, this is the first time i'm posting on this forum. this is also my first C++ programming class. i've basically written my program but its the last line that keeps showing up as an error message..

    Code:
    cout << "According to your survey, an average of" "<< people <<" 
    
      rode the "<< line <<" "per day. \n";
    what am i missing?? honestly i feel pretty silly for asking but i really can't figure it out. :|

  2. #2
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25
    oops its actually error 2065.. lol. sorry!!

  3. #3
    Registered User
    Join Date
    Mar 2008
    Location
    Coimbra, Portugal
    Posts
    85
    I see two (or three, it really depends on repetition) things wrong with your code. I believe that you should be able to see them for yourself.

    Throw ideas at the forum wall.

  4. #4
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25
    im pretty sure it has to do with how many quotation marks i have but whenever i take them out i have 4 errors instead of 3.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Location
    Coimbra, Portugal
    Posts
    85
    Quote Originally Posted by helloalyssa View Post
    im pretty sure it has to do with how many quotation marks i have but whenever i take them out i have 4 errors instead of 3.
    First, don't split a string ("this is a string") across lines.

    Second, if you're printing a string, it should "Look like this", and not ""like this" or "like this "" " " " " " " " " """

    So here's how I would do it:

    Code:
    cout << "According to your survey, an average of "<< people <<" rode the "<< line <<" per day.\n";
    If that doesn't fix your error, then according to Compiler Error C2065 (C++) you may be referencing an undeclared variable or function. Be it cout, people or line. Can you give more code if it doesn't work?
    Last edited by Jorl17; 09-19-2010 at 05:09 PM.

  6. #6
    Registered User helloalyssa's Avatar
    Join Date
    Sep 2010
    Posts
    25
    ohh okay wow. i feel pretty silly. i only broke up the string because it made it easier to read.. sigh. thank you for helping me with my silly problem. hopefully next time i make another post it'll be a little less elementary. thanks again!

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I think you are confusing yourself. Let's look at that code:

    cout << "According to your survey, an average of" "<< people <<"
    rode the "<< line <<" "per day. \n";

    The red part is clearly a string. No doubt.
    But if you look at the next part, you see that it begins with a quote which extends over the << people <<, which means that this is also a string! So this entire portion is a string. Probably not what you wanted!
    Now take a look at the blue text. This does not begin with a ", so it is not a string! The compiler doesn't know what "rode the" means and so it gets confused and spits out errors.
    Next, take a look at the orange text. This is clearly a string, with a space. This is OK.
    Then take a look at the green text. Again a missing " in the beginning, so it is not a string. It is, in fact, an error, because the compiler does not, once again, know what "per day" means, and spits out errors.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed