how do you declare code?

This is a discussion on how do you declare code? within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> int main() { int age; char string[256]; cout<<"Please enter your name and birthdate: "; cin>>string>>age; cout<<"Welcome"<<string<<","<<age<<endl; system ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    14

    how do you declare code?

    Code:
    #include <iostream>
    int main()
    {
     int age;
     char string[256];
     cout<<"Please enter your name and birthdate: ";
     cin>>string>>age;
     cout<<"Welcome"<<string<<","<<age<<endl;
     system ("pause");
     return 0;
    }
    I get several error of my cout and cin ( and endl) commands being undeclared, but how do you declare something?

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    using namespace std; is your friend

    or use the older header, iostream.h

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
     int age;
     char string[256];
     cout<<"Please enter your name and birthdate: ";
     cin>>string>>age;
     cout<<"Welcome"<<string<<","<<age<<endl;
     system ("pause");
     return 0;
    }

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    could you also give me a list of the different streams like iostream and that stuff and what their functions are?

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    i rmemeber a link on here about exactly what your asking, but cant remember it exactyl...looking around now.

    edit: this is kinda what your looking for, but not the one im thinking of.
    Last edited by Jamsan; 06-03-2003 at 12:42 AM.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    "could you also give me a list of the different streams like iostream and that stuff and what their functions are?"

    cin--input from your keyboard.
    cout--output to your display.

    Both are defined in <iostream>.

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    fstream is for files
    istringstream is for input stringstreams
    ostringstream is for output stringstreams

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 08:34 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 11:20 AM
  3. banking2
    By sweet2awy in forum C++ Programming
    Replies: 7
    Last Post: 08-01-2003, 04:01 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

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