error expected initializer before name

Write your question here.
Hello i am complete beginners in this coding language.I am trying to self learning of c++ from the book of bjarne stroustrup programming principles and practice using c++ but i stuck at this point

cout<< "please enter your name and age\n";
string first name;
int age;
cin>>first name;
cin>>age;
cout<< "Hello,"<<first name<<"(age"<<age<<")\n";

i wrote exactly same which is written in book and cross cheque it for several time but whenever i try to debug it codeblock always says error expected initializer before name in 8th line(string first name)

please help me
Hey,

you cannot use space in variable name. Use first_name instead of first name.
Hope that helps
Last edited on
Hi,

Welcome to cplusplus :+)

Variable names cannot have spaces in them - did you miss an underscore or something?

Hope all goes well.

Edit:

Oh, and can we ask you to always use code tags when you post? Select your code, then press the <> button on the format menu. It shows line numbers and formats the code better.
Last edited on
extremely thanq
Topic archived. No new replies allowed.