User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,678 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 3881 | Replies: 2
Reply
Join Date: Jan 2005
Posts: 15
Reputation: Foxtildawn is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Foxtildawn Foxtildawn is offline Offline
Newbie Poster

Help input data from a file into an Array

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Posts: 43
Reputation: Siersan is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
Siersan's Avatar
Siersan Siersan is offline Offline
Speaker of Truth

Re: input data from a file into an Array

  #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
inData.open(fileName.c_str()); 

for (int i = 0; inData>> T[i]; i++)
  ++size;
Reply With Quote  
Join Date: Dec 2004
Location: Devon - UK
Posts: 420
Reputation: 1o0oBhP is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: input data from a file into an Array

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 11:13 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC