I am currently doing online tutorials for C++, and am pretty much stuck in a rut about this problem. It is saying that there's an expected unqualifed-id before '{' token (I will post the code in just a second) on line 11, and an expected ',' or ';' before '{' token also on line 11, however I don't have a clue what the first one means. The program is meant to save a user's name in a string variable within a structure, and to then show that name without the need to assign a pointer to it. Also, note that I am compiling this with the Dev-C++ (aka Devcpp) compiler, on a Windows XP system.
11 C:\Documents and Settings\Main\M y Documents\subst ring and structures.cpp expected unqualified-id before '{' token
11 C:\Documents and Settings\Main\M y Documents\subst ring and structures.cpp expected `,' or `;' before '{' token
Could someone please explain to me what the "unqualifie d-id before" means, how to fix it, what I did wrong, and why it is the way that you say is the correct code?
Code:
#include <iostream>
using namespace std;
int main()
{
struct database {
string name; // declares that the structure has a string
// in it called name.
}
{
int main()
cout<<"Enter your name.\n"; //displays the obvious
getline(cin, name, '\n'); // records the user's input into the string name,
// and terminates the command when the user presses enter.
database employee01;
// declares the single structure and its contents
employee01.name = string name;
cout<<"Your name should be: "<<employee01.name<<".\n";
cin.get();
}
}
11 C:\Documents and Settings\Main\M y Documents\subst ring and structures.cpp expected `,' or `;' before '{' token
Could someone please explain to me what the "unqualifie d-id before" means, how to fix it, what I did wrong, and why it is the way that you say is the correct code?
Comment