My code runs on codepad http://codepad.org/dDI3fx92
but I get
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
on Visual STudio. Can someone take a look?
You configured your project incorrectly - When you ran the New Project Wizard, you selected Win32 Application instead of Console Application as the project template. To fix this, go to:
On the Toolbar, click on Project and select Project Properties. On the top of the window that is created, you'll see a drop-down menu labeled "Configuration." Change the value to "All Configurations." Then, in the pane on the left of the window, traverse to Configuration Properties->Linker->System.
In the right pane, you'll see a field labeled "Subsystem." It is currently set to Windows. Click the drop-down menu (arrow on the right) and select Console, and then run your program.
Also, you're likely to get a compile error for not returning from main (), but that's somewhat irrelevant.