PDA

View Full Version : Error C2447


lightbulb365
Jul 1, 2009, 01:27 PM
I get the following error:

----- Build started: Project: Program++, Configuration: Debug Win32 ------
Compiling...
Helloworld.cpp
Name.cpp
c:\parish\generic_pa_1\program++\program++\name.cp p(6) : error C2447: '{' : missing function header (old-style formal list?)
Generating Code...
Build log was saved at "file://c:\Parish\Generic_Pa_1\Program++\Program++\Debug\B uildLog.htm"
Program++ - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

When I tried compliling the following program on VC++2008:

#include<iostream>
#include<string>



{
using namespace std;
string s;
cout << "Please enter your first name followed by a newline\n";
cin >> s;
cout << "Hello, " << s << '\n';
return 0; /* this return statement isn't necessary */
}

Please help.

grim_2020
Jul 9, 2009, 04:37 AM
You are not defining a function there.



#include<iostream>
#include<string>

int main()
{
using namespace std;
string s;
cout << "Please enter your first name followed by a newline\n";
cin >> s;
cout << "Hello, " << s << '\n';
return 0; /* this return statement isn't necessary */
}

lightbulb365
Jul 9, 2009, 06:39 AM
I figured the function definition part out. However it wasn't as straightforward as that. VC++ does not like it if there are more than one programs open at the same time. It expects a function declaration only once (in one of the open programs) in that case. That was the reason why I didn't have a declaration to begin with. However after the error messages I decided to have just the one program open (with a function declaration) and it worked!

grim_2020
Jul 9, 2009, 03:13 PM
I believe you have multiple c++ files with main entry points in the same project instead of creating a new project for each program.

Project with multiple main's

http://img407.imageshack.us/img407/8869/pic1ssr.jpg

Multiple projects with one main

http://img31.imageshack.us/img31/4447/pic2dzf.jpg