Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define BUFFERSIZE 1024
- //
- void MyFile(const char* fn);
- int main(void)
- {
- MyFile("C:\\123.txt");
- //
- system("PAUSE");
- return 0;
- }
- void MyFile(const char* fn)
- {
- FILE * pFile_Read = NULL;
- char buffer[BUFFERSIZE] = {0};
- // 開檔:讀取檔案
- pFile_Read = fopen(fn, "r");
- if ( pFile_Read == NULL )
- {
- printf("檔案開啟失敗...\n");
- }
- else
- {
- printf("%s ", fn);
- while( feof(pFile_Read) == 0 ){
- fgets(buffer, BUFFERSIZE, pFile_Read);
- printf("%s ", buffer);
- }
- fclose(pFile_Read);
- printf("\n");
- }
- }
Add Comment
Please, Sign In to add comment