int feof(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; } char caReadBuffer[20]; int iIndex = 0; // Get characters until the we hit the end of the file. while (!feof(qpFile)) { caReadBuffer[iIndex] = (char)getc(qpFile); ++iIndex; } // Add a null terminator caReadBuffer[iIndex] = 0; // Output the read contents of the file printf("Text of %s:\n%s\n", cpFileName, caReadBuffer); fclose(qpFile); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.