C/stdio.h/fgetc

Материал из C\C++ эксперт
Версия от 13:23, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

fgetc: gets a character from the stream and increments the file position pointer

<source lang="cpp">

//Header: #include <stdio.h> //Declaration: int fgetc(FILE *stream); //Return: EOF: if the end of the file is reached.

 #include <stdio.h>
 #include <stdlib.h>
 int main(int argc, char *argv[])
 {
   FILE *fp;
   char ch;
   if((fp=fopen("test","r"))==NULL) {
     printf("Cannot open file.\n");
     exit(1);
   }
   while((ch=fgetc(fp)) != EOF) {
     printf("%c", ch);
   }
   fclose(fp);
   return 0;
 }


      </source>