Image

Imagebooticon wrote in Imagecpp

weird c++ problem

here's a function that i wrote for a program for school:

void calcloFN(int integer[], int & lo, int count)
{
          lo = integer[0];
	cout << "lo = " << lo << endl;
	int x = 1;

	cout << count << endl;
	
	while(x <= count)
	{
		if(integer[x] < lo)
			lo = integer[x];
		cout << "lo = " << lo << endl;
		x++;
	}
}


For some reason, lo is the right value until the last iteration of the while loop, which then goes to 0. WTF is up?