newb help needed

This is a discussion on newb help needed within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> int main() { int x = 5; int y = 7; cout "n/"; cout << x + ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    3

    newb help needed

    Code:
    #include <iostream.h>
    int main()
    {
        int x = 5;
        int y = 7;
        cout "n/";
        cout << x + y << "" << x * y;
        cout "n/";
        return 0;
    }
    okay whats the deal with this error message " expected `;' before string constant "

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Code:
    cout "n/";
    That'd be the deal. You need the << operator. Also you should stop looking at code through a mirror, because what you want is '\n' not 'n/'.

    ..and also, if by "" you mean space, then you want " "
    Last edited by SlyMaelstrom; 12-08-2005 at 05:57 PM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Code:
    cout "n/";
    That is an error. Reread the relevant section of your book on escape sequences.

    Code:
    cout << x + y << "" << x * y;
    What do you think you are doing there?

    Code:
    #include <iostream.h> ---> <iostream>
    okay whats the deal with this error message " expected `;' before string constant "
    In the future mark the line in your code where the error is occurring with a comment or highlight it in red.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Quote Originally Posted by 7stud
    Code:
    cout "n/";
    That is an error. Reread the relevant section of your book on escape sequences.
    I wouldn't really call that an error since there is nothing illegal about it (the red part that is), but as I said, it's not gonna do what he expected.

    On a side note, to the author of this topic, I'd like to add that this is something you should have no problem debugging yourself. I can understand that little things like this sometimes don't pop out like they should because your tired and maybe have been staring at the screen too long. But the error you received was *syntaxual and it's the kind of thing you should make a good attempt at debugging yourself. Just a tip so you could one day become a very good programmer.



    *No that isn't a real word.
    Last edited by SlyMaelstrom; 12-08-2005 at 01:45 PM.
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    14
    But 'syntactical' is one

  6. #6
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91
    don' t you also need like

    using namespace std; or sumthin like that
    Verbal Irony >>

    "I love english homework!" When really nobody like english homework.
    -Mrs. Jennifer Lenz (English Teacher)

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    In his case where he is including <iostream.h> he doesn't need to use the std namespace. If he were to switch it to <iostream> which is defined under the std namespace, he would need to use it in his program.
    Sent from my iPadŽ

  8. #8
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91
    o and its supposed to be
    Code:
    "/n"
    and instead of the /n , use endl;


    p.s.
    Thanks sly, im extremly rusty and I did not know that
    Verbal Irony >>

    "I love english homework!" When really nobody like english homework.
    -Mrs. Jennifer Lenz (English Teacher)

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    >> o and its supposed to be "/n"

    The correct point was already made. It should be "\n" or '\n', not "n/" or "n\" or "/n".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. Newb Question Character Counting
    By Wilder in forum C Programming
    Replies: 13
    Last Post: 06-22-2008, 11:37 PM
  4. Total newb directx invisable geometry question
    By -pete- in forum Game Programming
    Replies: 5
    Last Post: 08-13-2006, 01:45 PM
  5. Newb C++ Programmer
    By Philandrew in forum C++ Programming
    Replies: 8
    Last Post: 10-19-2004, 08:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21