Storing data from a dataset to an array ASAP!

I have a problem storing data to an array. I know how to READ the array using <fstream>, but is there a way how to store it to array[]? Please respond ASAP. I appreciate all the help!! Also: please use very basic language, as I am just beginning...

This is what I have so far:

int array[MAX_ARRAY_SIZE];
cout << "The original array: " << endl;
while (infile >> next)
{
cout << next << " ";
cout << " ";
count += 1;
}
I'm basing this code on the fact that the data your reading in are integers.

All you have to do is simple add a counter, we'll say i, and increment it after each storing of the data. this will move along the array index.


int array[MAX_ARRAY_SIZE];
///////////////////new code///////////////////////
int i = 0; // our array index
//////////////////////////////////////////////////////
cout << "The original array: " << endl;
while (infile >> next)
{
cout << next << " ";
cout << " ";

////////////////new code///////////////
array[i] = next; // assign the value of next to array[i]
i++; // same as i += 1;
///////////////////////////////////////////
count += 1;
}

i is the variable we're using to move through the array. you can output the array in a
similar fashion. Hope that helps.

Topic archived. No new replies allowed.