Strange error message...

Here's my program...




#include ;

#include ;


///////////////////////////////////////////////////////


void main() {


hello();


}


///////////////////////////////////////////////////////


void hello(void) {


cout<<"Hello World!"<<endl;<p>
}




At the line where I call the function 'hello' I get an error "Function 'hello' should have a prototype." What does that mean and how do I fix it??


Comments

  • If the function doesn't exist before the function calling it, the function will return that error.


    To prevent this add a copy of the function's function declaration terminated with a semi-colon (instead of the brackets with code in it) to the beginning of your source code. In fact, for code readability, the first real function (one with code in brackets) should be the main function. The other functions should follow it with their copies of their function declarations at the top.


    Example:


    #include stdio.h


    int print_hello();


    int main()

    {

    printf("This is before print_hello();
    ");

    print_hello();

    return 0;

    }


    int print_hello()

    {

    printf("Hello
    ");

    return 0;

    }


    -Xotor-




    : Here's my program...


    :

    : #include ;

    : #include ;


    : ///////////////////////////////////////////////////////


    : void main() {


    : hello();


    : }


    : ///////////////////////////////////////////////////////


    : void hello(void) {


    : cout<<"Hello World!"<<endl;<p>
    : }


    :

    : At the line where I call the function 'hello' I get an error "Function 'hello' should have a prototype." What does that mean and how do I fix it??





  • : Here's my program...


    :

    : #include ;

    : #include ;


    : ///////////////////////////////////////////////////////


    : void main() {


    : hello();


    : }


    : ///////////////////////////////////////////////////////


    : void hello(void) {


    : cout


    int hello(void);


    int main(void)

    {

    hello();

    }


    int hello(void);

    {

    printf("hello!");

    return(0);

    }




    I hope that can help you out. :)


    P.S. Any functions that are below main must be decliared just like above. This is to let the compiler know the functions are there. :)



    WICKET





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories