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

Recommended Answers

All 2 Replies

Member Avatar for Siersan

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;

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"....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.