C file input/output 2D arrays.

Reply

Join Date: Apr 2004
Posts: 1
Reputation: MrCool is an unknown quantity at this point 
Solved Threads: 0
MrCool MrCool is offline Offline
Newbie Poster

C file input/output 2D arrays.

 
0
  #1
Apr 16th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 77
Reputation: infamous is an unknown quantity at this point 
Solved Threads: 2
infamous infamous is offline Offline
Junior Poster in Training

Re: C file input/output 2D arrays.

 
0
  #2
Apr 16th, 2004
how bout using fwrite()?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 219
Reputation: BountyX is an unknown quantity at this point 
Solved Threads: 8
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Re: C file input/output 2D arrays.

 
0
  #3
Apr 17th, 2004
create a stream for file out put and write to that stream like u would with cout
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC