943,931 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 9868
  • C RSS
Jan 30th, 2005
0

input data from a file into an Array

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Foxtildawn is offline Offline
15 posts
since Jan 2005
Jan 30th, 2005
0

Re: input data from a file into an Array

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;
Reputation Points: 12
Solved Threads: 2
Light Poster
Siersan is offline Offline
45 posts
since Jan 2005
Jan 31st, 2005
0

Re: input data from a file into an Array

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"....
Reputation Points: 16
Solved Threads: 6
Posting Pro in Training
1o0oBhP is offline Offline
445 posts
since Dec 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: Help please beginner in C
Next Thread in C Forum Timeline: Right Justified / decimal point alignment





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


Follow us on Twitter


© 2011 DaniWeb® LLC