[CODE]#include "stdio.h"
int main(void)
{
FILE *fp = NULL;
int cnt = 0;
char line[1024] = "";
if((fp=fopen("c:\\WIN-TC\\projects\\puttext.txt","r"))==NULL)
{
printf("Cannot open file puttext any key exit!");
// getch();
exit(1);
}
printf("Can open file puttext!\n");
while(fgets(line, 1024, fp) != NULL)
{
++cnt;
printf("Line %d: %s", cnt, line);
}
fclose(fp);
putchar('\n');
return 0;
}[/CODE]
你参考一下,修改一下就能得到你想要的功能
int main(void)
{
FILE *fp = NULL;
int cnt = 0;
char line[1024] = "";
if((fp=fopen("c:\\WIN-TC\\projects\\puttext.txt","r"))==NULL)
{
printf("Cannot open file puttext any key exit!");
// getch();
exit(1);
}
printf("Can open file puttext!\n");
while(fgets(line, 1024, fp) != NULL)
{
++cnt;
printf("Line %d: %s", cnt, line);
}
fclose(fp);
putchar('\n');
return 0;
}[/CODE]
你参考一下,修改一下就能得到你想要的功能
猝然临之而不惊,无故加之而不怒 /?spaced" target="_blank">Linux C资料