wrote this program thats not working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream.h>
#include <iomanip.h>
int main()
{
    using std::string;        
    string fullname;
    string address;
    string citystatezip;
    string number;
    cout << "Enter full name: ";
    getline(cin, fullname);
    cout << "Enter your address: ";
    getline(cin, address);
    cout << "Enter your city state and zip code: ";
    getline(cin, citystatezip);
    cout << "Enter your phone number: ";
    getline(cin, number);
    cout << "Your information you entered is: "
    cout << setw(10) << fullname << setw(10) << address << setw(10) << citystatezip << setw(10) << number << endl;
    return 0;
}
tell us what the problem is: http://www.cplusplus.com/forum/articles/40071/#msg218019

nolyc wrote:
iostream is the correct header, not iostream.h. And as with any standard C++ header the contents are in the std namespace. That means std::cout instead of cout, std::endl instead of endl and so forth.
okay my problem is when i try to compile it it says line 19 has an error
error - expected i before cout so should i try std::cout on all of them?
and i need the program to output the stuff you input just relaying the info back to the user
Last edited on
line 18 should end in a semicolon `;'
what about line 19? with the
|19|error: `setw' undeclared (first use this function)|
|19|error: (Each undeclared identifier is reported only once for each function it appears in.)|
nvm i found it had to add an
#include <iomanip> for it to work thanks for your help though!
To answer your question about std::cout, yes you would need to use that since the only thing you qualified to use std:: namespace was string. You could add similar directives for cout and endl, or use std::cout and std::endl. To be fair, I'm not sure if you have to pass cin to getling using std:: or not though.
Last edited on
Topic archived. No new replies allowed.