Hello, I am new to C++ and I am trying to call a function. I wrote this code with experience in other languages thinking it would work. I am getting an error 'expected a declaration'. It is a very basic print line just to check how functions work in C++. The winmain function is because I was getting an error earlier asking for something called winmain. 'unresolved external symbol _WinMain@16 referenced in function' Anyway here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include<Windows.h>
//Testing the function named foo
void foo(void)
{
//this is what the function is going to do
OutputDebugStringA("This is outputting to the debug string and it is the first thing I have ever printed in C++.\n");
}
//using winmain due to error caused earlier see post found on MSDN
int CALLBACK WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow);
{
foo();
}
EDIT: got it working, removed the ; after int nCmdShow)
Hi am new to C++ well if you're a real newbie , why not start learning about c++ basics before moving directly into Windows programming, life would be abit easier for you- piece of advice ;)