hey i jst need a lil help with dis...

void main()
{

	for(int polygon = 0;polygon < 3;polygon++)
	{
	int i, j;
	const int max =5;
	int end;
	int sort;
	int ymin = 21;
	int start;
	int ypos;
	int vertices=0;



	if(polygon == 0)
	{
		float x0[] = {20, 40, 90, 120, 70};
		float x1[] = {40, 90, 120, 70, 20};
		float y0[] = {20, 120, 130, 60, 90};
		float y1[] = {120, 130, 60, 90, 20};

	}

	else if(polygon == 1)
	{
		float x0[] = {200, 200, 240, 300, 300, 250};
		float x1[] = {200, 240, 300, 300, 250, 200};
		float y0[] = {50, 80, 120, 70, 20, 60};
		float y1[] = {80, 120, 70, 20, 60, 50};

	}
	
	else
	{
		float x0[] = {400, 400, 420, 450, 450, 480, 500, 475, 445, 445};
		float x1[] = {400, 420, 450, 450, 480, 500, 475, 445, 445, 400};
		float y0[] = {40, 80, 110, 110, 80, 80, 70, 20, 20, 40};
		float y1[] = {80, 110, 110, 80, 80, 70, 20, 20, 40, 40};

	}
	cout << x0[vertices] << " "; <--------problem
	}
}

da error is saying that x0 is not declared...help!!!

  1. Please use [code][/code] tags when posting code - see the readme first threads.

  2. void main()
    main returns an int.

  3. for(int polygon = 0;polygon < 3;polygon++)
    This doesn't compile - polygon isn't declared. Try to post what you actually compiled.
    There's no way for us to guess whether what you missed out and is causing a problem, or what you missed out just to make a shorter post.

  4. cout << x0[vertices] << " "; <--------problem
    Well all of your arrays go out of scope at the } which follows each if statement.

Maybe something like

float x0[][10] = {
  {20, 40, 90, 120, 70},
  {200, 200, 240, 300, 300, 250},
  {400, 400, 420, 450, 450, 480, 500, 475, 445, 445}
};
cout << x0[polygon][vertices];

Edited 3 Years Ago by diafol: fixed formatting

3.

for(int polygon = 0;polygon < 3;polygon++)

This doesn't compile - polygon isn't declared. Try to post what you actually compiled.

was that a slip of the brain? or are you working in C90 mode today? :)

This article has been dead for over six months. Start a new discussion instead.