user15873596
user15873596

Reputation: 165

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.

Upvotes: 12

Views: 3266

Answers (2)

orion elenzil
orion elenzil

Reputation: 5443

Slightly more minimal take than Vlad's -

Declare it like this:

void viderBuffer(void) { ... }

Upvotes: 0

Vlad from Moscow
Vlad from Moscow

Reputation: 311088

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

void viderBuffer( void );

And define it also like

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

Upvotes: 13

Related Questions