Feof

Feof

feof is a C standard library function declared in the header stdio.h. Its primary purpose is to distinguish between cases where a stream operation has reached the end of a file and cases where the EOF ("end of file") error code has been returned as a generic error indicator, without the end of the file's actually having been reached.

Function prototype

The function is declared as follows::int feof(FILE *fp);It takes one argument: a pointer to the FILE structure of the stream to check.

Return value

The return value of the function is an integer. A nonzero value signifies that the end of the file has been reached; a value of zero signifies that it has not.

Example code

#include int main() { FILE *fp = fopen("file.txt", "r"); int c; c = getc(fp); while (c != EOF) { /* Echo the file to stdout */ putchar(c); c = getc(fp); } if (feof(fp)) puts("End of file was reached."); else if (ferror(fp)) puts("There was an error reading from the stream."); else /*NOTREACHED*/ puts("getc() failed in a non-conforming way."); fclose(fp); return 0; }

References

* [http://groups.google.com/groups?selm=1152560118.121927@news1nwk&dmode=source "How to detect an empty file?"] , Eric Sosman, posting to the comp.lang.c Usenet group, 10 Jul 2006
* [http://c-faq.com/stdio/feof.html Question 12.2] of the C FAQ


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Feof — feof  функция стандартной библиотеки языка Си, объявленная в заголовочном файле stdio.h. Ее основное назначение  отличать случаи, когда операции потока достигают конца файла, от случаев, когда возвращается код ошибки EOF («конец файла» …   Википедия

  • feof — feof·for; …   English syllables

  • feof|fer — «FEHF uhr, FEE fuhr», noun. a person who grants a fief or fee …   Useful english dictionary

  • feof|for — «FEHF uhr, FEE fuhr», noun. = feoffer. (Cf. ↑feoffer) …   Useful english dictionary

  • feoffor — feof·for (fĕfʹər, fēʹfər) n. Variant of feoffer. * * * …   Universalium

  • feoffor — feof·for …   English syllables

  • EOF — Saltar a navegación, búsqueda EOF (abreviatura de end of file, fin de fichero en inglés) es un indicador o marca de que no hay más información que recuperar de una fuente de datos. La fuente de datos puede ser un fichero o un flujo de datos… …   Wikipedia Español

  • Файловый ввод/вывод в языке Си — Язык программирования Си поддерживает множество функций стандартных библиотек для файлового ввода и вывода. Эти функции составляют основу заголовочного файла стандартной библиотеки языка Си <потоками байтов, которые могут быть как потоками… …   Википедия

  • Feoffee — Feof*fee (?; 277), n. [OF. feoff[ e].] (Law) The person to whom a feoffment is made; the person enfeoffed. [1913 Webster] …   The Collaborative International Dictionary of English

  • Feoffer — Feofor Feo for, Feoffer Feof fer, n. [OF. feoour.] (Law) One who enfeoffs or grants a fee. [1913 Webster] …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”