So I'm trying to create 4 arrays with data input from a .dat file, and for some reason it won't.
The file has four columns, and I want four arrays with the info from each column seperate.
For some reason, I'm having trouble doing that with the following code (minus header info):

//Creating my class members
    ifstream infile;
    Rocket ship;
    
    //My arrays and their pointers
    float alltime [7528];
    float *t = alltime;
    float allheight [7528];
    float *h = allheight;
    float allv [7528];
    float *v = allv;
    float alla [7528];
    float *a = alla;
   
    //Creating my most excellent arrays
    while (infile.good())
    {
          infile >> *t >> *h >> *v >> *a;
          t = t+4;
          h = h+4;
          v = v+4;
          a = a+4;
    }
    if (infile.eof())
          cout <<  "End of file reached\n"<<endl;
    else  {
          cout << "Input terminated for unknown reason\n";
          }
    infile.close();
    
    //Finishing up!
    cin.get();
    return 0;
}

So far I just get 4 giant arrays, but filled with 0s
What needs to be done in order to fix this?

you are making a mountain out of a molehill. Your code is much too difficult.

//Creating my class members
    ifstream infile;
    Rocket ship;
    
    //My arrays initialized to 0
    float alltime [7528] = {0};
    float allheight [7528] = {0};
    float allv [7528] = {0};
    float alla [7528] = {0};
   
    //Creating my most excellent arrays
    int i = 0;
    while (i < 7528 && infile >> alltime[i] >> allheight[i] >> allv[i] >> alla[i])
         i++;
t = t+4;
          h = h+4;
          v = v+4;
          a = a+4;

Although you don't need the above code, to answer your question all you have to do to increment pointers of any size is this:

t++;
          h++;
          v++;
          a++;
commented: The moderator helped me see a way of writing code that I had completely passed. Thanks! +1

Thanks for that. I got caught up in pointer arrays and such.
Speaking of which, I'm trying to send those arrays to my class functions, and it doesn't seem to want to work.
Based on the same code I submitted above, I added

ship.Rocket_Fall(int i, float alltime[], float allheight[]);

to my int main, and

void Rocket::Rocket_Fall(int i, float alltime[], float allheight[])
{
     int j=0, indext=0;
     max_h = allheight[j];
     for (j=0, j<i, j++)
     {
         if (allheight[j] > max_h)
         {
            max_h = allheight[j];
            indext = j;
         }
     }
     fall_t = alltime[indext];
}

to my function definitions. What needs to change to properly send those arrays?

Nevermind, I just changed the arrays to be class members and it takes care of everything, making life 500x better.

Thanks for your help.

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.