1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
int main()
{
float *doub1, *doub2;
char *line, *rest, lines, *line2, filename[100], ch;
FILE * newfile;
printf("enter file name: ");
scanf("%s", filename);
newfile = fopen(filename, "r+");
while (ch = fgetc(newfile) !=EOF)
{
if (ch == '\n')
{
lines++;
}
}
for (int i = 0; i < lines/2; i++)
{
fgets(line, 100, newfile);
sscanf(line, "%e %s", doub1, rest);
fgets(line2, 100, newfile);
sscanf(line, "%f %s", doub2, rest);
if (doub2>doub1)
{
fputs( "\n", newfile);
}
doub2=doub1;
line2=line;
}
return 0;
}
|