int ferror(FILE* qpStream);
#include <cstdio> int main() { char* cpFileName = "XoaX.txt"; FILE* qpFile = fopen(cpFileName, "r" ); // Check that the file was opened if (!qpFile) { printf("Could not open %s for reading \n", cpFileName); return 1; } // Create an error by trying to write to the read only file putc('a', qpFile); // Get the error type int iResult = ferror(qpFile); if (iResult != 0) { printf("Reading Error: %i\n", iResult); return 1; } fclose(qpFile); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.