Write your question here.
I am writing a code for my advanced c++ class and I believe I have done everything correctly but keep getting the LNK2019 error. I have searched for how to fix it but the more I look it up the more I get confused. Im not to sure if its something with the code thats causing this or if its what I am using, I am currently running Visual Studio 2019 through Amazon AppStream (VMWare).
Put the code you need help with here.
Here is what I have so far...
#include <iostream>
#include <string>
using namespace std;
current = current->next;
}
cout << "number of people surveyed: " << total << endl;
cout << "number of females: " << female << endl;
cout << "number of males: " << male << endl;
cout << "number of females who got the vaccine: " << fvac << endl;
cout << "number of males who got the vaccine: " << mvac << endl;
cout << "number of people under 21: " << u21 << endl;
cout << "number of people under 21 who got the vaccine: " << uvac << endl;
cout << "number of people 21 or older: " << g21 << endl;
cout << "number of people 21 or older who got the vaccine: " << gvac << endl;
cout << "number of people who trust the vaccine: " << trust << endl;
cout << "number of people who do not trust the vaccine: " << ntrust << endl;
cout << "number of people who think masks should be required: " << mask << endl;
cout << "number of people who think the vaccine should be required: " << vac << endl;
cout << "percent of females: " << fper << endl;
cout << "percent of males: " << mper << endl;
cout << "percent of females getting the vaccine: " << fvacper << endl;
cout << "percent of males getting the vaccine: " << mvacper << endl;
cout << "percent of people under 21 who got the vaccine: " << uvacper << endl;
cout << "percent of people older than 21 who got the vaccine: " << gvacper << endl;
cout << "percent of people who trust the shot: " << trustper << endl;
cout << "percent of people who think masks should be required: " << maskper << endl;
cout << "percent of people who think vaccine should be required: " << vacper << endl;
}
The error I am receiving is LNK2019- unresolved external symbol_main referenced in function "int_cdecl invoke_main(void)" (?, invoke_main@@YAHXZ)... MSVCRTD.lib(exe_main.obj) line 1
If you believe we've memorised every VS numerical error code, you're very much mistaken. If you're getting an error message, then show us the complete error message.
The error I am receiving is LNK2019- unresolved external symbol_main referenced in function "int_cdecl invoke_main(void)" (?, invoke_main@@YAHXZ)... MSVCRTD.lib(exe_main.obj) line 1
Then all I can say is to slowly, gradually put your stuff back in, such that you can see a point A where it works, and a point B where it doesn't work, and then post the exact code for both instances. (Source control and file diffing help a lot here.)
current = current->next;
}
cout << "number of people surveyed: " << total << endl;
cout << "number of females: " << female << endl;
cout << "number of males: " << male << endl;
cout << "number of females who got the vaccine: " << fvac << endl;
cout << "number of males who got the vaccine: " << mvac << endl;
cout << "number of people under 21: " << u21 << endl;
cout << "number of people under 21 who got the vaccine: " << uvac << endl;
cout << "number of people 21 or older: " << g21 << endl;
cout << "number of people 21 or older who got the vaccine: " << gvac << endl;
cout << "number of people who trust the vaccine: " << trust << endl;
cout << "number of people who do not trust the vaccine: " << ntrust << endl;
cout << "number of people who think masks should be required: " << mask << endl;
cout << "number of people who think the vaccine should be required: " << vac << endl;
cout << "percent of females: " << fper << endl;
cout << "percent of males: " << mper << endl;
cout << "percent of females getting the vaccine: " << fvacper << endl;
cout << "percent of males getting the vaccine: " << mvacper << endl;
cout << "percent of people under 21 who got the vaccine: " << uvacper << endl;
cout << "percent of people older than 21 who got the vaccine: " << gvacper << endl;
cout << "percent of people who trust the shot: " << trustper << endl;
cout << "percent of people who think masks should be required: " << maskper << endl;
cout << "percent of people who think vaccine should be required: " << vacper << endl;
}
I have fixed the initial errors, but 3 new ones popped up on the same line.
E0169 says expected a declaration
C2059 says syntax error: ‘}’
C2143 says syntax error: missing ‘;’ before ‘}’,
Use code formatting. Edit your post and add [code] and [/code] around your code.
If you follow proper indentation, errors like that are much less likely: Around line 41 is the end of main. The code you have after that is not part of main, and the }; at the end (~line 47) is not matched with anything.