help with compiler trouble. Cout verification?

This is a discussion on help with compiler trouble. Cout verification? within the C++ Programming forums, part of the General Programming Boards category; ok everything works great on my compiler except for my cout, cin. when i try to compile my program it ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    4

    Unhappy help with compiler trouble. Cout verification?

    ok everything works great on my compiler except for my cout, cin. when i try to compile my program it tells me i need to verify cout, and cin. this is my second day programming so please dont flame.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    Post your code in code tags, tell us which compiler you are using, and how you are compiling the code. Read the sticky posts at the top of the forum.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    4
    Code:
    # include (iostream)
    
    using namespace std;
    
    int main ()     // Most important part of the program!
    {
        int age;    // need a variable...
        
        cout<< " please input your age: "; // asks for age
        cin>> age;     // tHE INPUT IS PUT IN AGE
        cin.ignore();  // tHROW AWAY ENTER
        if ( age < 100){  // iF AGE OS ;ESS THAN 100
             cout<< " you are pretty young!!\n"; //JUST TO SHOW IT WORKS
    
    }
    else if ( age == 100){    // USED JUST TO SHOW EXAMPLE
         cout<<"you are old\n";  // SHOWS IT WORKS
         }
         else {
              cout<<"you are really old\n";  // EXECUTES IF NO OTHER STATMENT IS
              }
              cin.get();
              }

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    4
    oops sorry for got to type. i am using bloodshed and my compiler tells me that all my cout and cin. need to be declared.
    Last edited by bigd5; 05-31-2005 at 06:55 PM. Reason: mistake

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    Simple problem. It should be <iostream>, not (iostream).

    Also, if that is the way your program is tabbed in your Dev-C++ IDE, then you should probably reformat it to make it cleaner. It will still compile, but that is really hard to read.

    Maybe like this:
    Code:
    # include <iostream>
     
    using namespace std;
     
    int main ()	 // Most important part of the program!
    {
    	int age;	// need a variable...
     
    	cout<< " please input your age: "; // asks for age
    	cin>> age;	 // tHE INPUT IS PUT IN AGE
    	cin.ignore(); // tHROW AWAY ENTER
     
    	if ( age < 100){ // iF AGE OS ;ESS THAN 100
    		cout<< " you are pretty young!!\n"; //JUST TO SHOW IT WORKS
    	}
    	else if ( age == 100){	// USED JUST TO SHOW EXAMPLE
    		cout<<"you are old\n"; // SHOWS IT WORKS
    	}
    	else {
    		cout<<"you are really old\n"; // EXECUTES IF NO OTHER STATMENT IS
    	}
     
    	cin.get();
    }

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    4
    what do you mean by reformat. Im new i just started yesterday. i see the mistake i made now thanks. but what do you mean by reformat. like make more spaces and stuff.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,338
    Like I showed in the code I added to my post. The braces are indented evenly and each block of code is properly indented. My version doesn't look as nice because of a bug in the forum software that turns four spaces into really big tabs, but you should get the idea. Compare my version with yours and see which one is easier to see where the if ends, where the main function ends, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Which Compiler?
    By Bladactania in forum C Programming
    Replies: 10
    Last Post: 02-11-2009, 12:32 AM
  2. [resolved] internal compiler error...
    By bling in forum C++ Programming
    Replies: 2
    Last Post: 12-10-2008, 11:57 AM
  3. having trouble with ifstream
    By Shy_girl_311 in forum C++ Programming
    Replies: 1
    Last Post: 12-03-2001, 02:42 AM
  4. Having trouble with my compiler
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-26-2001, 11:33 PM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM

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