i am getting this error when i want to build my cpp file.
Severity Code Description Project File Line Suppression State Error C2447 '{': missing function header (old-style formal list?) Win32Project1 d:\\persoonlijk\\documenten\\2e leerjaar\\c++\\win32project1\\win32project1\\leerlinggegevens_hfst3.cpp 2
Here is the code i am using:
/*Hoofdstuk 3, Leerlinggegevens*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
int lnr;
string lnm;
string oplnm;
string klasm;
//DECRALEREN
cout << "Voer je leerlingnummer in: \n";
cin >> lnr;
cout << "Vul je naam in: \n";
cin >> lnm;
cout << "Vul je opleiding in: \n";
cin >> oplnm;
cout << "Vul je klas in: \n";
cin >> klasm;
cout << "Jouw ingevulde leerleerlinggegevens bestaan uit: \n" << "Leerling " << lnr << " met leerlingnummer " << lnm << "staat ingeschreven bij opleiding " << oplnm << " \n" << "Leerlingnummer " << lnr << " zit in klas " << klasm << endl;
system("PAUSE");
}
Thanks for your time!
Your code works fine in Windows environment it seems.
In case you are running on Linux environment, but I am not quite sure whether system("PAUSE");
works over there or not. Even, this seems to me as non - portable code.
I would recommend you to use cin.get()
or getchar()
instead, to make it portable. If you want to more why I am saying so, you can go through this link: http://www.gidnetwork.com/b-61.html
The source code you posted compiles just fine with both Microsoft Visual C++ 2015 and gcc (tried on ideone.com).
The only way to get the C2447 compile error you are getting, with Visual C++, is to add a semi-colon (;) right after main():
int main();
{
(but Visual Studio 2015 editor highlights the error, even before compiling the code).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.