ma com'è che se implemento il tuo codice nel mio prog, non funzia ?
codice:
#include <stdio.h>
#include <stdio.h>
#include <string.h>
char *f (char *);
int main(void) {
char done[100];
char *stato;
FILE *file;
file = fopen("state.sah", "r");
/* open a text file for reading */
if(file==NULL) {
printf("Seti@Home ha finito di elaborare la WorkUnit.\n");
return 1;
}
else {
while(fgets(done, 100, file)!=NULL) {
if(strstr(done,"prog=0.")) { printf("%s",done);
printf ("%s \n", f (done)); }
}
fclose(file);
system ("PAUSE");
return 0;
}
}
char *f (char *s) {
float f;
char *p = (char *) malloc (sizeof (s));
if (strstr (s, "prog="))
s = s + 5;
f = atof (s);
f = f * 100;
sprintf (p, "%2.2f%%", f);
return (p);
}
come output mi da :
prog=0.64155436
229339200.00%