I made a quick program as my first venture into c++ but it seems to be buggy. As far as i can see my code seems logical, but the endl; above firaddress seems to be interfeering. Can anyone help please?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << endl << "Please enter your first name" << endl << endl;
cin >> name;
string surname;
cout << endl << "Please enter your surname" << endl << endl;
cin >> surname;
cout << endl << "your name is " << name << " " << surname << endl << endl;
string firaddress;
cout << "Please enter the first line of your address" << endl << endl;
getline (cin, firaddress);
string secaddress;
cout << "Please enter the second line of your address" << endl << endl;
getline (cin, secaddress);
string towaddress;
cout << "Please enter your town" << endl << endl;
getline (cin, towaddress);
string posaddress;
cout << "Please enter your postcode" << endl << endl;
getline (cin, posaddress);
cout << endl << endl << "Your address is..." << endl << endl << firaddress <<
endl << secaddress << endl << towaddress << endl << posaddress<< endl << endl;
system("pause");
/*cin.get(); is an alternative, doesnt work with
the above function as intended, program auto closes*/
}