#include
#include
#define MAX 81
int main(void)
{
char name[30],content[MAX];
int row,column;
FILE *fp;
printf("input the name of file:");
gets(name);
if( ( fp=fopen(name,"r") ) == NULL )
{
printf("Can't open %s",name);
exit(1);
}
printf("input the row and column to output:");
while ( scanf("%d%d",&row,&column) == 2 )//求每一步解释
{
row--,column--;
fseek(fp,0,SEEK_SET);
while (row--) fgets(content,MAX,fp);//简便起见,未做一些越界判断
fseek(fp,column,SEEK_CUR);
fgets(content,MAX,fp);
printf(content);
printf("input the start position to output:");
}
printf("Quit\n");
return 0;
}
编写一个程序,打开一个文本文件,文件名通过交互方式获得。建立一个循环,请求用户输入一个文件位置。然后程序打印文件中从该位置开始到下一换行符之间的部分。用户通过输入非数字字符来终止输入循环。
while循环里的都是啥意思?row,column的作用??