an error

This is a discussion on an error within the C++ Programming forums, part of the General Programming Boards category; Code: //after a long time, i figured this out #include <iostream> using namespace std; int main() { double ans1; int ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    36

    Question an error

    Code:
    //after a long time, i figured this out
    
    #include <iostream>
    using namespace std;
    
    int main()
    
    {
        double ans1;
        int x;
           
        
        cout<<"Hi there! I am PC, the computer. What's your name?:" << endl;
        cout<<"Hi " <<endl;
        cout<<"Game?:";
        cin >>x;
        
         
        if(x==1)
        {
            cout<<"All right! Ok... This is a questionaire! You answer correctly,
            "you move on. 1 question. 1st question:"<<endl<<endl;
            
            cout<<"What is 398+276?: "<<endl;
            cin>>ans1;
            
            if(ans1==674)
            {
                cout<<"That is correct!!!";
            }
            else
            {
                cout<<"Wrong!";
            }
        }
        
        cin.get();
        return 0;
    }

    the compiler says that line #15 has errors. that line is the first cout. it says missing terminating "character

    what the heck am i missing here.

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    The error I get is on line 21, the first cout inside the if. It is because your string doesn't have a trailing " on that line. Your string can span two lines, but you must have both lines in their own quotes, or use a forward slash to continue to the next line and remove the quote there.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    If your compiler supports it, you can attempt to do what you are doing by putting a '\' at the end of the above line. But its best to do as jlou suggested as all compilers accept:

    Code:
    "multi"
    "-"
    "line"
    " "
    "strings like this"

  4. #4
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    i moved a " away, then it works fine

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    
    {
        double ans1;
        int x;
           
        
        cout<<"Hi there! I am PC, the computer. What's your name?:" << endl;
        cout<<"Hi " <<endl;
        cout<<"Game?:";
        cin >>x;
        
         
        if(x==1)
        {
            cout<<"All right! Ok... This is a questionaire! You answer correctly,
            you move on. 1 question. 1st question:"<<endl<<endl;
            
            cout<<"What is 398+276?: "<<endl;
            cin>>ans1;
            
            if(ans1==674)
            {
                cout<<"That is correct!!!";
            }
            else
            {
                cout<<"Wrong!";
            }
        }
        
        cin.get();
        return 0;
    }

    blow me ... ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

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