So Yeah,i decide to download Visual Studio Community 2015 because i wanted to do c++ for fun,for my first program i tried like what everyone else would do a simple text print,copied the command straight from the c++ tutorial ,some reason it didnt work,which makes no sense why it wouldnt work since its taken from the first tut page from c++!,so ive been trying lots of things and went from millions of errors to like 1,yesterday i watched a tut from a person and he had the exact same version,and i copied his code,and put it into mine in the right order and its not working,nothing is,its like its just making up invalid errors and its really annoying,still pretty mad that the code from the begginer tut from this website wouldnt work,.ill paste the code that should work in the space below
so the errors its been giving out are things like stdafx.h and other things,now its saying this, LNK2019 unresolved external symbol_WinMain@16 reference in function "int_cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
which shouldnt be showing becayse this code is the exact same code that the tut used,except i edited it to say Hello There! Instead Of World.
Your code does not refer to anything that the stdafx does provide, so there is no reason to have line 4. The stdafx is not part of C++ standard. There is no justification for using it in a C++ tutorial.
You do properly and explicitly refer to the std::cout, so you don't actually need the line 7 either.
Tutorials have been written at some point in time, using some version of a toolchain, by persons with some understanding about the language, for audience likely to be on same platform as the author. Even if they might have been proper at the time of writing, the situation has changed and the C++ language itself has evolved.
MS Visual Studio is not the only C++ toolchain available for MS Windows. For example MSYS2 and mingw-w64 do build even more complex programs just fine. MS Visual Studio is not even the only IDE for Windows (although it might be good). For example Code::Blocks has been mentioned.
@keskiverto The stdafx is not part of C++ standard This may be true, but it is part of the Visual Studio standard and needs to be there for the file to compile.
Hello YThisNoWork,
Other than the redundancy of using std::cout because line 6 negates the use of std:: I see no problem with your code. I tried the code in my Visual Studio 2015 and could not generate any errors.
Post the errors that you are getting so we have a better idea of what is going on.
The only thing I can think of right now is that the path to the include files may not be correct. stdafx.h includes stdio.h and tchar.h and targetver.h which includes SDKDDKVer.h. If these file can not be found it will be a problem when the file is linked as in the error LNK2019 unresolved external symbol.... Sounds to me that something was used that is defined in a header file that was not included.
The OP is creating the wrong type of project. He is creating some kind of windowing program instead of a console program.
I don't do Windows and therefore don't use Visual Studio and I don't remember how exactly to fix the issue, maybe some Windows expert will shed so light on this subject.