This code is a work in progress, it's nowhere near finished...but I'm getting these unfamiliar errors when attempting to compile it.error LNK1120 and error LNK2019. What the heck is going on here?
99 times out of 100, "unresolved external symbol" means you are trying to call a function that doesn't have a body. The name of the function should be in the error message.
Also, this is unrelated to your error, but line 24 is all wrong. getinput doesn't return anything (it's a void), so how can you print it? Also, you need to give it parenthesis if you want to call the function (ie getinput())
It's only a problem if you try to use one that you haven't written yet. The error messages should tell you which functions it can't find (unresolved external). Which functions can't it find?
Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup C:\Users\\documents\visual studio 2010\Projects\8A\8A\MSVCRTD.lib(crtexew.obj) 8A
The joy of learning to program using a huge IDE that you don't understand. You have to learn to program AND learn C++ AND learn how to use the IDE all at the same time.
"cout <<" means output something, for example a string like "Hello", in this case to the console. You cant output a function in that way, You have to call the function. Like this
int main()
{
getinput();
}
Also main does not return anything, Set its type to void or return with 0.
Thats now quite how it works, Read on functions again, You can only output a function if it returns something. And your function returns void. So this is impossible.
EDIT: I saw that you got a good answer, But i still would suggest you to read my link and not move on in your program before you understand it completely!
Yeah....that's exactly what I was trying to do. Thanks!
This is what gives me the hardest time with this stuff. Understanding why your code works and mine didn't. The syntax and logic on this stuff gives me nightmares.
It's obvious I still don't fully grasp this function stuff...I tried writing the code for the second function, and while it compiles, it doesn't output anything. I know something is not quite right with the code, but I'm not sure what. I know the problem must be in lines 8,23, 24, or 42....or maybe I don't need to open the file again?
It's because once main returns a value, the program ends. The function looks like it should work. Also, I know C++ ignores whitespace, but having all of those extra lines at the end of your program is not very nice -.-
It's because once main returns a value, the program ends.
1 2 3 4 5 6 7 8 9 10 11
int main()
{
getinput();
// main function ends once it returns
// omit this line
return 0;
// Everything after this doesn't get run
average ();
// But leave this
return 0;
}