943,799 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 9934
  • C RSS
Apr 16th, 2004
0

C file input/output 2D arrays.

Expand Post »
Hi there,

I am currently converting a matlab file to C, and need some help writing the data calculated in 2D arrays to files.

This is what i ahve done so far:

<snip>
File *U;
File *V;
File *X;
File *Y;
U = fopen("U.txt", "w");
V = fopen("V.txt", "w");
X = fopen("X.txt", "w");
Y = fopen("Y.txt", "w");


<snip>
float U[N][N];

<snip> Here i do some calculations to fill the array with the new values.

i am not too sure how to make it write to the file...i have done this so far..

for (int i=0; i<N-1; i++){
for(int j=0; j<N-1; j++){
fprintf(Uvalues,"\n",U);
}
}

to get the values of the 2D array U to write to the file.

Any help will be much appreciated..

Steven
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MrCool is offline Offline
1 posts
since Apr 2004
Apr 16th, 2004
0

Re: C file input/output 2D arrays.

how bout using fwrite()?
Reputation Points: 47
Solved Threads: 2
Junior Poster in Training
infamous is offline Offline
77 posts
since Mar 2004
Apr 17th, 2004
0

Re: C file input/output 2D arrays.

create a stream for file out put and write to that stream like u would with cout
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: value of learning computer theory
Next Thread in C Forum Timeline: connection program for sybase





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC