waarschuwing: incompatibele impliciete verklaring van ingebouwde functie ‘printf’ [standaard ingeschakeld]

Ik gebruik de volgende C-code:

#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
int main()
{
    int file=0;
    if((file=open("testfile.txt",O_RDONLY)) < -1)
            return 1;
    char buffer[19];
    if(read(file,buffer,19) != 19)  return 1;
    printf("%s\n",buffer);
    if(lseek(file,10,SEEK_SET) < 0) return 1;
    if(read(file,buffer,19) != 19)  return 1;
    printf("%s\n",buffer);
    return 0;
}

Na het compileren geeft het een waarschuwing:

warning: incompatible implicit declaration of built-in 
function ‘printf’ [enabled by default]

Wat betekent het en hoe sussen ik de C-compiler om de waarschuwing niet te verhogen?


Antwoord 1, autoriteit 100%

Je moet #include <stdio.h>bovenaan je bestand toevoegen.

Other episodes