System:IO:Stream and text file issue

Hi guys,

I've got a very simple piece of code that at present has me stumped. I'm reading a text file consisting of ten lines of ten characters (or a file of one line of one hundred characters) with a System:IO:Stream (from an open file dialog) and assigned the value of a property two dimensional array.of objects.

This should be simple (ignoring line breaks):
1
2
3
4
5
6
7
8
9
10
11
void MapInterface::LoadMap(Stream^ inStream)
{
	for (int x = 0; x < 9; x++)
	{
		for (int y = 0; y < 9; y++)
		{
			int temp = int(inStream->ReadByte());//Ascii 49 = 1
			mapArray[x][y]->m_Density = temp;
		}
	}
}


The temp int isn't necessary, but just makes watching the read in values easier when debugging. The issue is that even though int temp is assigned a relevant value from the stream, an attempt to assign [0][9] mysteriously fails. The array is [10][10] in size.

Consider that the first line of the file may be 1111222211 - this should read in as 49,49,49,49,50,50,50,50,49,49. When we reach [0][9], temp is correctly assigned 49. mapArray[0][9] refuses to assign, and crashes.

Any ideas? I'm a bit miffed.

Thanks,

Luke
Topic archived. No new replies allowed.