#include <stdio.h>
main()
{
FILE *fp;
char s[256];
int i = 1;
fp = fopen("abc_.txt", "r");
if(fp == NULL)
return;
while(feof(fp) == 0){
fgets(s, 255, fp);
printf("%04d: %s", i, s);
i++;
}
fclose(fp);
}
위의 코드대로 작성한다음
abc_.txt 파일을
[code:1]abcdefg[엔터]
hijklmn[엔터]