Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gmcguinn

macrumors newbie
Original poster
Jan 20, 2011
28
0
Dublin, Ireland
Code:
[COLOR="Lime"]// ******************************************************* //
//    Program to grasp the idea of the getline function                           //
// ******************************************************  //[/COLOR]


#include <iostream>
#include <string>
using namespace std;

int main ()
{
	int age; 
    string zipcode,name,address;
	
    cout << "Please enter your name\n";
    getline(cin,name);
    cout << "Please enter your age\n";
    cin >> age;
    cout << "Please enter your zipcode\n";
    cin >> zipcode;
    cout << "Please enter your address\n";
    getline(cin,address);
    
    
    cout << "Your details : "; 
    cout << name;
    cout << age << " years old."; 
    cout << address;  
    cout << zipcode "\n";
    
    return 0;
}

This is the error I get when run in terminal

address.cpp: In function ‘int main()’:
address.cpp:28: error: expected `;' before string constant (line 27 is cout << address;)
make: *** [address] Error 1


Cheers
 
Last edited:
So the error message says the problem is in line 28 -- and you've identified line 28 (since you know which one is line 27.) Does anything look wrong on that line?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.