Array help

I have to make the program sort values. My professor told me easiest way would be to put the values in a array first. I am to assume there will be no more the 50 values.

This is what I have so far. the string efile coming in is the file name (test).
I got the values into the array but when I display the values I end up with -9.25596e+061 for any value of the array not initialized. How would i go about doing this so that this doesnt happen.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  void operation3(string efile)
{
	ifstream infile;
	int i=0, x=0, count=0;
	const int y=50;
	efile += ".txt";
	infile.open(efile.c_str());
	double numbers[y];
	while (infile >> i)
		{
			numbers[x] = i;
			x++;
		}
	while (count < y)
	{
		cout << numbers[count] << endl;
		count++;
	}
	system ("pause");
}
Use while (count < x) so as to output only the elements of the array which have been assigned a value.
wow that was simple, thank you very much
Topic archived. No new replies allowed.