Hi All
Can anyone tell me how to read a file but only print to the screen certain parts of it? Below is what I've got already - apologies if it's very basic, I'm new to this! All I can do is get a program which prints the whole file to the screen. What I need to do is create a program which can pick out numbers from the file which are higher than 0.7 and print only those to the screen. I have looked everywhere for examples of this but no joy.
Any advice would be appreciated.
Thanks
#include <stdio.h>
#include <stdlib.h>
#include <clib.h>
int main()
{
printf("Please enter the name of the file you require: ");
FILE *z;
char x[1000];
char fname[128];
gets(fname);
z=fopen(fname,"r");
if (!z)
return 1;
while (fgets(x,1000,z)!=NULL)
printf("%s",x);
return (0);
}