I bought Sams Teach yourself C++

Hello I'm new to this website. I love video games, and I hate working in warehouses. I want to learn how to program so I bought a book called Sams Teach yourself c++. I'm at the part where it tells me to download windows visual studio. It tells me to create a win32 console application and name the project.
Then it says to uncheck the Precompiled Header option, and I did. Then it says replace the automatically generated content, and replace with the code:

1
2
3
4
5
6
7
8
9
  
  #include <iostream>

  int main()
  {
     std:cout << "Hello World!" << std::endl;
     return 0;



After that it says press ctrl+f5 to run the program directly via the IDE. This compiles, links, and executes your application. But I'm getting errors. I have double checked multiple times and it is typed correctly. Can anyone tell me whats wrong with my setup. I highly doubt a well published book would tell me incorrect code. What is wrong with my setup? The error says:

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _WinMain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) WindowsProject2 c:\Users\PC\source\repos\WindowsProject2\WindowsProject2\MSVCRTD.lib(exe_winmain.obj)
before you say you need the closing bracket, i did, but im used to the program putting it in for me so i naturally forgot to put it in here, i did use a closing bracket
Line 6
 
    std:cout

should be
 
    std::cout

note the double ::

Line 8
missing closing brace.

Ok - I read your post and explanation. But I used the cpp.sh link Next to your code in the post above, to the top-right is a button with a gear icon , labelled 'Edit & Run'. Click there, it takes you to an online compiler with your code, where you can compile and run it.
Last edited on
yea i made an error there as well, i put the double :: in line 6 for both cout and endl, I still get an error in windows visual.
IT RUNS!?! Why doesn't it work in microsoft visual express?
> Error LNK2019 unresolved external symbol _WinMain@16

Choose "Win32 Console Application" as shown in step 4 of this tutorial:
https://www.visualstudio.com/vs/support/hello-world-c-using-visual-studio-2017/
I copy and paste from whats in my wvs

#include<iostream>

int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
still getting error
> Error LNK2019 unresolved external symbol _WinMain@16

Choose "Win32 Console Application" as shown in step 4 of this tutorial:
https://www.visualstudio.com/vs/support/hello-world-c-using-visual-studio-2017/


I did, even though my user interface doesnt look like that, when i choose the platform it says:

Windows Desktop Application
A project for creating a Windows desktop (Win32) application.
OMG THE PROGRAM LIES. It says i was using widows 32 but i wasnt?

I chose to use the Windows console application, and it works now?
But it says windows desktop application is a (win32)..im confused yo
Alas, you have purchased a bad book. SAMS teach yourself books are garbage, and on the list of C/C++ books you don't want. http://www.cs.technion.ac.il/users/yechiel/CS/BadBooksC+C++.html

MSVS names things naturally, but for a beginner it can be confusing.
Anything you compile on Windows is a Win32 application (unless you are knowingly cross-compiling for, say, Android or something).

There is, however, a significant difference between a console application and a GUI application. MSVS also creates sub-catagories of those depending on what libraries you intend to use.

For your purposes, you only need start with a straight-up, empty, non-anything else, C++ console application (for Win32).
Topic archived. No new replies allowed.