Ethan Ellsworth Ethan Ellsworth - 1 year ago 172
C++ Question

Error C244 '{': missing function header (old-style formal list?) Visual C++

I've been looking at a lot of questions similar to mine but all of the answers are about how something is just wrong in the code. So I've been looking in mine and I can't find anything wrong with it. Though I guess it makes sense since I'm just starting out with C++. Here is the code:

#include <windows.h>
#include <conio.h>

int Main = MessageBox(NULL, "Testing", "Testing", MB_YESNO);
if (Main == IDYES) {
MessageBox(NULL, "Testing2", "Testing", NULL)

else if (Main == IDNO) {
MessageBox(NULL, "Testing3", "Testing", NULL)


return 0;

Answer Source

Your program needs to define a function called main. The main function is what gets called by the environment when your program starts running.

(main and Main are distinct identifiers, but I suggest that using the name Main for an object could be confusing.)

The definition of the main function should look like this:

int main() {
    // code goes here

The #include directives are fine where they are, but everything else should be inside the definition of main.

More complex structures are possible (for example you can have file-scope declarations and multiple function definitions), but this should get you started.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download