Created
October 19, 2010 07:57
-
-
Save johnhmj/633811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment