[问题点数:50分]
比如如何读取第二行Zmini. : 后面这个-60
2018-05-09 19:14
2018-05-09 20:07
程序代码:#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main(void)
{
FILE *fp = NULL;
char buf[3000] = { 0 };
int count = 0;
int row = 0;
int ch = 0;
fp = fopen("G:\\outil1.par", "r");
if (fp == NULL)
{
printf("Cann't open the file!\n");
exit(1);
}
else
{
//----------------------------------------------------------------------------
while (1)
{
printf("Input a row you want to read: \n");
scanf("%d", &row);
fflush(stdin);
while (!feof(fp))
{
fgets(buf, 3000, fp);
count++;
if (row == count)
{
printf("%s", buf);
}
memset(buf, 0, sizeof(buf));
}
count = 0;
rewind(fp);
printf("go on? [y/n]: ");
scanf("%c", &ch);
fflush(stdin);
//----------------------------------------------------------------
if (ch == 'y' || ch == 'Y')
{
continue;
}
else
{
break;
}
}
fclose(fp);
}
system("pause");
return 0;
}
2018-05-09 20:40
2018-05-09 22:58