Simple example for this error C2447

I'm very new to programming, just starting out this week. That said, I am doing a simple Hello World program in VS2005. Here is the code

1
2
3
4
5
6
7
8
9
#include <iostream>
int main();
using namespace std;
{
	std::cout << "Hello World\n";
	char return;
	std::cin >> return;
	return 0;
}


which compiles with an error of

error C2447: '{' : missing function header (old-style formal list?)

I have found a number of ppl with this error but all using much more complicated examples.

How do I fix this error? I've tried everything I can possibly think of.
Any help is appreciated

K
Look at lines 2 and 3 - it is blindingly obvious.
Other error: you are using the keyword 'return' as variable name
Thank you, I was able to fix it but I don't know why removing the extraneous semi-colon and the 'using namespace std;' line fixes that error.
The function body shouldn't be separed from its head
Think that this is like typing int i; using namespace std; = 5; instead of int i = 5;
Last edited on
Topic archived. No new replies allowed.