Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C (https://www.askmehelpdesk.com/forumdisplay.php?f=438)
-   -   Error C2447 (https://www.askmehelpdesk.com/showthread.php?t=371035)

  • Jul 1, 2009, 01:27 PM
    lightbulb365
    Error C2447
    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.
  • Jul 9, 2009, 04:37 AM
    grim_2020
    You are not defining a function there.

    Code:

    #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 */
    }

  • Jul 9, 2009, 06:39 AM
    lightbulb365
    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!
  • Jul 9, 2009, 03:13 PM
    grim_2020
    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

  • All times are GMT -7. The time now is 04:24 AM.