cfunction-declarationfunction-prototypesparameter-list

How to prevent error : this old-style function


I am following a tutorial and my code seems normal but I got a message which says

This old-style function definition is not preceded by a prototype

code.c :

void viderBuffer()
{
    int c = 0;
    while (c != '\n' && c != EOF)
    {
        c = getchar();
    }
}

Thanks you for your help. Sorry if my post is not perfect I am new here.


Solution

  • Declare the function before main (or before referencing it in main) like

    void viderBuffer( void );
    

    And define it also like

    void viderBuffer( void )
    {
        //...
    }