Ferror - examples

Nasza ocena:

3
Wyświetleń: 819
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Ferror - examples - strona 1 Ferror - examples - strona 2

Fragment notatki:

Ferror Tests for an error on a stream. int ferror( FILE * stream ); • 0 means: no error has occurred on stream • Otherwise: a nonzero value • The ferror routine tests for a reading or writing error on the file associated with stream • If an error has occurred, the error indicator for the stream remains set until: - the stream is closed - or rewound - or until clearerr is called #include int main(void) { FILE *stream; /* open a file for writing */ stream = fopen("Test.txt", "w"); /* force an error condition by attempting to read */ (void) getc(stream); if (ferror(stream)) /* test for an error on the stream */ { /* display an error message */ printf("Error reading from Test.txt\n"); /* reset the error and EOF indicators */ clearerr(stream); } fclose(stream); return 0; } ... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz