Expected ';' before string constant

So i wrote this program to be sent as a practical joke, and ive reduced the errors to this:"Expected ';' before string constant"
there are 3 of them and i dont exactly know what is wrong.
here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int name,DateOfBirth,PlaceOfBirth;
    cout<<"Please enter your name:\n";
    std::cin>>name"\n";
    cout<<"Hello, "<<name<<", please enter your date of birth:\n";
    std::cin>>DateOfBirth"\n";
    cout<<"Now enter your place of birth:\n";
    std::cin>>PlaceOfBirth"\n";
    cout<<"Thank you, "<<name<<", your identity has just been stolen.\n";
    cout<<"Have a nice day, formerly "<<name<<".\n";
    cout<<"Program Terminated\n";
    system ("PAUSE");
    return 0;
}

the errors are on lines 8, 10, and 12. your help is much appreciated, thank you.

Last edited on
Those "\n" in the cins are completely out of place. Remove them.
ok, thank you, but now when i execute the program, i enter my name, and is refers to me as "2".
then when i hit enter, it causes the rest of the dialogue appear automatically. any pointers there?
Do you realize you're trying to use an integer to store a name, right? Since you've already included string, why don't you use an std::string?
jesus, of course! thank you
quick question though, i cant use an integer to store a name, or does an integer have to have numerical value?
Last edited on
Well, your question doesn't make much sense, but from what I can tell, you're asking me if an integer must have a numerical value. The answer is yes, but, it's not always safe to access this value:
1
2
3
4
5
6
7
int a; //a is uninitialized
int b=a;
/*
The behavior here is system-dependent. Some systems let you get away with it,
but Windows XP, for instance, detects this as a runtime error and crashes the
program.
*/
Last edited on
ok, to rephrase, even though you already answere my question,
"can i store a name with an integer, or does it have to have numerical value?"
that better?
thank you, by the way
No. You can only store a numerical value in an int.
Last edited on
Topic archived. No new replies allowed.