Hi to all, I have a file like this one :
...
...
ncfft=22492
cr=-9.301750e+000
fl=131072
cpu=6976.765625
prog=0.64155436
potfreq=-1
potactivity=0
outfilepos=2113
bs_power=188.316513
bs_score=0.672828
bs_bin=91475
...
...
Now, i can read it with fgets untill i read the line i was looking for :
prog=0.64155436
But..how can I say "if I find a line with prog=, save it in an array" ?
And once i've saved it, how can I modify that array for print, at the end, something like 64,15 (instead 0.64155436)
I should do something like :
thanx to everyoneCode:#include <stdio.h> int main() { char c[100]; /* declare a char array */ FILE *file; /* declare a FILE pointer */ file = fopen("file.txt", "r"); /* open a text file for reading */ if(file==NULL) { printf("Error: can't open file.\n"); /* fclose(file); return 1; } else { printf("File opened successfully:\n\n"); while(fgets(c, 100, file)!=NULL) { //PSEUDOCODE IF c ="prog=*" copy c-->array modify array } printf("\n\nNow closing file...\n"); fclose(file); system ("PAUSE"); return 0; } }