input data from a file into an Array

Reply

Join Date: Jan 2005
Posts: 15
Reputation: Foxtildawn is an unknown quantity at this point 
Solved Threads: 0
Foxtildawn Foxtildawn is offline Offline
Newbie Poster

input data from a file into an Array

 
0
  #1
Jan 30th, 2005
help!
im trying to input data from a file into an array. I cant figure it out...this is what i have:


inData.open(fileName.c_str());

int i=0;
while(inData)
{
inData >> T[i];
i++;
size++;
}

thanks
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 45
Reputation: Siersan is an unknown quantity at this point 
Solved Threads: 2
Siersan's Avatar
Siersan Siersan is offline Offline
Speaker of Truth

Re: input data from a file into an Array

 
0
  #2
Jan 30th, 2005
What you have should work, unless I'm too tired to see a problem. Another way to write it would be
  1. inData.open(fileName.c_str());
  2.  
  3. for (int i = 0; inData>> T[i]; i++)
  4. ++size;
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: input data from a file into an Array

 
0
  #3
Jan 31st, 2005
have you got any more code as if there is a problem you might need to show us the whole program. there is a good fstream tutorial on the site that can solve problems... Im not entirely sure but my RLE compression / De-compression snippet MIGHT have file -> array code, but I think I performed the routine "on-the-fly"....
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
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