#include <iostream>
#include <string> //here is the second directive to the compiler.
char middlename;
char lastname;
int main()
{ using namespace::std;
string name; //this is a declaration sentence.
cout << "What is your first name?" << endl;
cin >> name; //user designates name by typing value.
cout << "What is your middle name?" << endl;
cin >> middlename; //user designates name by typing value.
cout << "What is your last name?" << endl;
cin >> lastname;
cout << "Hello "<<name<<" "<<middlename<<" "<<lastname<<" "," "I hope you are having a good day.";
system("pause");
}
What did I do wrong? Btw: even though one line is forced back onto another line that's not what it's like on my program. my compiler told me line 15 (cout << "Hello " <<name<<....) was the problem. Please help me!
Thanks for all your help. I understand now. You were particularly helpful AbstractionAnon. The only question I have is what do you mean make lastname a string? I typed the same for the lastname as the middle and first, or so I think......
I really don't want to sound stupid, but this is my second program, and I am sad to say I don't know the difference between declaring a character, and a string. Please don't laugh.
#include <iostream>
#include <string> //here is the second directive to the compiler.
usingnamespace std;
int main()
{
string middlename;
string lastname;
string name; //this is a declaration sentence.
Please don't laugh.
It's all right - everyone has to start somewhere.
Try to look at examples & tutorials on the web or in a book - then extend them a bit - you will be flying in no time.