Fuction Headers

This is a discussion on Fuction Headers within the C++ Programming forums, part of the General Programming Boards category; I'm new at C++ and I have found the source for a program but when I compile it, it says: ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    Fuction Headers

    I'm new at C++ and I have found the source for a program but when I compile
    it, it says:

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

    the line number is 28 which is the line above 'string font="Default";'. Can somebody tell me what sort of function header will fix this?
    heres the source code:

    #include <iostream.h>
    #include <string>
    #include <stdlib.h>
    #include <conio.h>
    #include <fstream.h>
    #include <stdio.h>

    void menu()
    {
    system("cls");
    cout << "******************************\n";
    cout << "1.) Insert an Image\n";
    cout << "2.) Insert an Image Link\n";
    cout << "3.) Insert Text\n";
    cout << "4.) Insert Text Link\n";
    cout << "5.) Change Font\n";
    cout << "6.) Change Font Size\n";
    cout << "7.) Change Font Color\n";
    cout << "8.) Insert Horizontal Line\n";
    cout << "9.) Insert a Break\n";
    cout << "10.) Exit WebpageMakerv.1.1\n";
    cout << "******************************\n";
    }


    int string, main();

    {
    string font="Default";
    string fontsize="Default";
    string fontcolor="Default";
    string text;
    string hrcolor;
    string align;
    string address;
    string alink;
    string vlink;
    string link;
    string path;
    string color;
    ......

  2. #2
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    int string, main();

    The above should read int main()

    [EDIT] Without the semicolon and 'string' [EDIT]
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    problem

    but now it says:

    error C2065: 'string' : undeclared identifier

  4. #4
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    try replacing

    #include <string>

    with

    #include <string.h>
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    umm..

    it has 69 errors but If I put it back to how I had it, it only has the one. The top two are:

    'string' : undeclared identifier

    syntax error : missing ';' before identifier 'font'

  6. #6
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Can you please post your current code again?
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  7. #7
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163
    use memset() to place default for a string like this:

    char person[10];
    memset(person, '\0', 10);

    heres how it works:

    memset(string, "What you want in it", size);
    +++
    ++
    + Sekti
    ++
    +++

  8. #8
    Registered User
    Join Date
    Jun 2002
    Posts
    15
    Where would I include the memset. And do you want the full code ?

    #include <iostream.h>
    #include <string.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <fstream.h>
    #include <stdio.h>

    void menu()
    {
    system("cls");
    cout << "******************************\n";
    cout << "1.) Insert an Image\n";
    cout << "2.) Insert an Image Link\n";
    cout << "3.) Insert Text\n";
    cout << "4.) Insert Text Link\n";
    cout << "5.) Change Font\n";
    cout << "6.) Change Font Size\n";
    cout << "7.) Change Font Color\n";
    cout << "8.) Insert Horizontal Line\n";
    cout << "9.) Insert a Break\n";
    cout << "10.) Exit WebpageMakerv.1.1\n";
    cout << "******************************\n";
    }


    int main()
    {
    string font="Default";
    string fontsize="Default";
    string fontcolor="Default";
    string text;
    string hrcolor;
    string align;
    string address;
    string alink;
    string vlink;
    string link;
    string path;
    string color;
    string name;
    string title;
    string meta;
    cout << "~ Welcome to MaKiT Webpage Maker 1.0 ~\n";
    cout << "\nPlease enter a filename.html: ";
    getline(cin, name);
    ofstream kcout(name.c_str());
    kcout << "<html>\n<head>\n"
    <<"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">";
    cout << "Please Enter The Key words That Search Engines Will use to Describe Your page:\n";
    getline(cin,meta);
    kcout<<"\n<META NAME=\"keywords\" CONTENT=\""<<meta<<"\">\n";
    cout <<"\n\nPlease input a Description of you website:\n";
    getline(cin, meta);
    kcout << "<META NAME=\"description\" CONTENT=\""<<meta<<"\">\n";
    cout << "\n\nWhat is your Name: (Who is the author of this page)\n";
    getline(cin,meta);
    kcout << "<META NAME=\"author\" CONTENT=\""<<meta<<"\">\n";
    cout << "Press any key to continue...\n";
    system("cls");
    kcout << "\n<title>\n";
    cout << "What is the title of your WebPage: ";
    getline(cin ,title);
    kcout << title<<"\n</title>\n</head>\n";
    cout << "Press any key to continue...\n";
    getch();
    system("cls");
    cout << "Do you wish to have a picture or color for your background?\n";
    cout << "Type p or c here: ";
    string background;
    getline (cin ,background);
    cout << "Press any key to continue...\n";
    getch();
    system("cls");
    if (background=="p")

    ....

  9. #9
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Dunno about memset(). It's fine for char arrays. But he's using string data types here, Sekti.

    As for the error you keep getting, i find it odd. Even though you have the include for the string header file, it seems to insist on not recognizing the string name...

    What compiler are you using?
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  10. #10
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    using

    im using MS visual c++ 6.0

  11. #11
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Ok... just a thought here... remove the .h from the string include and put

    using namespace std;

    after the includes and before void menu()
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  12. #12
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    :-(

    102 errors now! weird or what?

  13. #13
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    err... yes weird. I'm afraid I may be misdirecting you

    Are most of these errors the kind of 'string' : undeclared identifier?
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  14. #14
    Registered User
    Join Date
    Jun 2002
    Posts
    15
    with the using namespace thing all the errors are like this:

    error C2780: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,co
    nst _E)' : expects 3 arguments - 2 provided

    without that they are like this:

    syntax error : missing ';' before identifier 'font'

    but the identifiers are different and there is the error:

    'string' : undeclared identifier

    at the start.

  15. #15
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    try <cstring.h> maybe?
    What is C++?

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-18-2005, 02:26 PM
  2. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  3. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  4. Precompiled Headers, are they necessary?
    By XenoCodex Admin in forum C++ Programming
    Replies: 2
    Last Post: 06-23-2002, 02:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21