[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
ferror() Test for Error on a Stream (Macro)
#include <stdio.h>
int ferror(stream);
FILE *stream; Pointer to file structure
ferror() is a macro that tests for reading or writing errors in
'stream'. If an error has occurred, the stream's error indicator
remains set until rewind() or clearerr() is called or until the
stream is closed.
Returns: Zero if no error has occurred. A non-zero value
indicates an error.
-------------------------------- Example ---------------------------------
The following statements open a file and check for reading errors.
#include <stdio.h>
FILE *in;
char str[50], *nstr;
main()
{
if ((in = fopen("text.dat","r+")) != NULL) {
.
.
nstr = fgets(str,50,in);
if (ferror(in)) {
printf("read error\n");
clearerr(in);
}
}
}
See Also:
clearerr()
rewind()
eof()
feof()
perror()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson