FILE* freopen(const char* kcpPath, const char* kcpMode, FILE* qpStream);
#include <cstdio>
int main()
{
char* cpFileName = "XoaX.txt";
// Open an ASCII text file for reading and
// redirect stdin to it.
FILE* qpFile = freopen(cpFileName, "r", stdin);
// Check that the file was opened successfully.
if (!qpFile) {
printf("Could not open %s\n", cpFileName);
return 1;
}
// Use stdin to read the first char of the file
int iReturn = getchar();
if (iReturn != EOF) {
printf("Read in: %c\n", (char)iReturn);
}
fclose(qpFile);
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.