Guest User

Untitled

a guest
Jun 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define BUFFERSIZE 1024
  5. //
  6. void MyFile(const char* fn);
  7. int main(void)
  8. {
  9. MyFile("C:\\123.txt");
  10. //
  11. system("PAUSE");
  12. return 0;
  13. }
  14. void MyFile(const char* fn)
  15. {
  16. FILE * pFile_Read = NULL;
  17. char buffer[BUFFERSIZE] = {0};
  18. // 開檔:讀取檔案
  19. pFile_Read = fopen(fn, "r");
  20. if ( pFile_Read == NULL )
  21. {
  22. printf("檔案開啟失敗...\n");
  23. }
  24. else
  25. {
  26. printf("%s ", fn);
  27. while( feof(pFile_Read) == 0 ){
  28. fgets(buffer, BUFFERSIZE, pFile_Read);
  29. printf("%s ", buffer);
  30. }
  31. fclose(pFile_Read);
  32. printf("\n");
  33. }
  34. }
Add Comment
Please, Sign In to add comment