Error C2447

Hi guys. I know you probably get this error a lot here but i cannot figure this out for the life of me. Here is the code i have written:

#include <iostream>
#include "stdafx.h"
using namespace std;

int main();
{

int c, thisIsAVariable, q76354, number;

cout << "Enter an integer: ";
cin >> age;

if (age != 7)
cout << "the variable number is not equal to 7" << endl;
cout << "This is a C++ program" << endl;
cout << "This is a C++ \n program" << endl;
cout << "This\nis\na\nC++\nprogram" << endl;
cout << "This\tis\ta\tC++\tprogram" << endl;

return 0;

}



Thanks in advance for any fixes :)
Most of us don't memorize the error codes.

What is the actual error message? What line is it on?


EDIT:

actually it's probably due to stdafx. precompiled headers have to be the very first thing included.

Solutions:

1) turn off precompiled headers. They're stupid for these small projects. (when you make a new project in visual studio, be sure to check the "empty project" checkbox in the wizard)

or

2) Move #include "stdafx.h" so that it is above #include <iostream>



EDIT 2:

Also, remove the semicolon after int main()
Last edited on
The header "stdafx.h" shall be the first header in list of headers.
Next time report the error message text. There are not telepathists in the forum.
thats crazy it was literally just having to remove the semicolon after int main()

thank you so much and next time i will remember to put up the full error code and message
And age wasnt declared anywhere as well...
Topic archived. No new replies allowed.