How to prevent error : this old-style function

2.8k views Asked by At

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.

2

There are 2 answers

1
Vlad from Moscow On BEST ANSWER

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

void viderBuffer( void );

And define it also like

void viderBuffer( void )
{
    //...
}
0
orion elenzil On

Slightly more minimal take than Vlad's -

Declare it like this:

void viderBuffer(void) { ... }