24,857
社区成员




#include <stdio.h>
char buf[32768];
FILE *f;
void getnoline(int no) {
int n;
n=0;
rewind(f);
while (1) {
if (NULL==fgets(buf,32768,f)) {
buf[0]=0;
break;
}
n++;
if (n>=no) break;
}
}
void main() {
f=fopen("abc.txt","r");
if (NULL==f) {
printf("Can not open file abc.txt!\n");
return;
}
getnoline( 1);printf("%s",buf);
getnoline( 10);printf("%s",buf);
getnoline(100);printf("%s",buf);
fclose(f);
}