void setbuf(FILE* qpStream, char* cpBuffer);
#include <cstdio>
int main()
{
char* cpFileName = "XoaX.txt";
// Open an ASCII text file for reading.
FILE* qpFile = fopen(cpFileName, "r");
// Check that the file was opened successfully.
if (!qpFile) {
printf("Could not open the file %s\n", cpFileName);
return 1;
}
// The buffer size must be BUFSIZ
char caBuffer[BUFSIZ];
// Set the buffer for the file stream
setbuf(qpFile, caBuffer);
// Read from the file.
char caRead[50];
fscanf(qpFile, "%s", caRead);
printf("String read: %s\n", caRead);
fclose(qpFile);
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.