* writing a large array to disk
@ 2002-09-19 18:27 Karthik Vishwanath
2002-09-19 19:45 ` Glynn Clements
0 siblings, 1 reply; 2+ messages in thread
From: Karthik Vishwanath @ 2002-09-19 18:27 UTC (permalink / raw)
To: C-programming
Hello,
I have a (fairly) large 4-d array in my program that I want to dump to
disk as text data (so that it may be suitably parsed later). I was
wondering if there was an easy (hopefully, single library call!) that
would do this?
If there is none, and I must write the data out "by hand", what would be
the most optimal way of doing this?
Thanks,
-K
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: writing a large array to disk
2002-09-19 18:27 writing a large array to disk Karthik Vishwanath
@ 2002-09-19 19:45 ` Glynn Clements
0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2002-09-19 19:45 UTC (permalink / raw)
To: Karthik Vishwanath; +Cc: C-programming
Karthik Vishwanath wrote:
> I have a (fairly) large 4-d array in my program that I want to dump to
> disk as text data (so that it may be suitably parsed later). I was
> wondering if there was an easy (hopefully, single library call!) that
> would do this?
No.
> If there is none, and I must write the data out "by hand", what would be
> the most optimal way of doing this?
Nested "for" loops:
double data[NI][NJ][NK][NL];
FILE *fp = ...;
...
fprintf(fp, "%f %f %f %f\n", NI, NJ, NK, NL);
for (i = 0; i < NI; i++)
for (j = 0; j < NJ; j++)
for (k = 0; k < NK; k++)
for (l = 0; l < NL; l++)
fprintf(fp, "%f\n", data[i][j][k][l]);
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-19 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-19 18:27 writing a large array to disk Karthik Vishwanath
2002-09-19 19:45 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).