1 Replies - 1291 Views - Last Post: 28 October 2006 - 08:03 PM Rate Topic: -----

#1 skelectron  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-October 06

Access Violation in For Loop

Posted 28 October 2006 - 07:14 PM

void ColForm(ostream ColPage, int **ColData, int ColPower)
{
	int n, x, y, mask;
	mask = ColPower;
	ColPage << "<table border = \"1\">" << endl;
	ColPage << "<p>Column Form</p>" << endl;
	for(x = 0; x < ColPower; x++)
	{
		ColPage << "<tr>" << endl;
		for(n = 1, y = 0; y < ColPower; y++)
		{
			for( mask = 0; ColData[x][y] != ColData[x+1][y]; x++)
			{
				n++;
			}
			if( ColData[x][y] != ColData[x+1][y] )
			{
				ColPage << "<th rowspan = \"" << n << "\">" << endl;
				ColPage << "<p>" << ColData[x][y] << "</p>" << endl;
				ColPage << "</th>" << endl;
				n = 1; 
			}
		}
		ColPage << "</tr>" << endl;
	}
	ColPage << "</table>" << endl;

}


I have the access violation error at

for( mask = 0; ColData[x][y] != ColData[x+1][y] ; x++) loop
can anybody tell me the reason, and what should i do to correct it....
thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Access Violation in For Loop

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Access Violation in For Loop

Posted 28 October 2006 - 08:03 PM

That error usually occurs when you've passed the bounds of the array...so it will be dependant on the values of x and y...one of them is likely incrementing one element too far.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1