Y
Yu SONG
Hi all,
What would be the most efficient way to save an array of floats to a
file (in text format)?
At the moment, my code looks like:
/*
* Saving an array of floats to a file
*/
void save(char* filename, float* src, int limit) {
FILE* fp = fopen(filename, "w");
if (fp != NULL) {
register int i;
for (i=0; i<limit; i++) {
fprintf(fp,"%.2f ", src);
}
fclose(fp);
} else {
printf("Error: Saving data !!!");
}
}
Is there a better way to do this? Thanks
--
Yu Song
/* E-mail.c */
#define User "Yu.Song"
#define At '@'
#define Host "warwick.ac.uk"
int main() {
printf("Yu Song's E-mail: %s%c%s", User, At, Host);
return 0;}
/*
Further Info. : http://www.dcs.warwick.ac.uk/~yu/
*/
What would be the most efficient way to save an array of floats to a
file (in text format)?
At the moment, my code looks like:
/*
* Saving an array of floats to a file
*/
void save(char* filename, float* src, int limit) {
FILE* fp = fopen(filename, "w");
if (fp != NULL) {
register int i;
for (i=0; i<limit; i++) {
fprintf(fp,"%.2f ", src);
}
fclose(fp);
} else {
printf("Error: Saving data !!!");
}
}
Is there a better way to do this? Thanks
--
Yu Song
/* E-mail.c */
#define User "Yu.Song"
#define At '@'
#define Host "warwick.ac.uk"
int main() {
printf("Yu Song's E-mail: %s%c%s", User, At, Host);
return 0;}
/*
Further Info. : http://www.dcs.warwick.ac.uk/~yu/
*/