|
-
January 24th, 2013, 04:45 AM
#4
Re: Writing Structure to CSV file - won't work... HELP!
 Originally Posted by Protocol
...
Code:
struct SizeAll{
int year;
double R;
};
int write_to_file(int count, struct SizeAll *data, char const *fileName)
{
FILE *f = fopen(fileName, "w");
if (f == NULL) return -1;
while (count-- > 0) {
// you might want to check for out-of-disk-space here, too
fprintf(f, "%d,%d", data->year, data->R);
++data;
}
fclose(f);
return 0;
}
Why do you format the double R as integer? Does it make any real sense in your case?
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|