How do I change the value of a 2d array using a 1d array?

So I want use a 1d array to change the value of a 2d array if one of the values in the 2d array equal k. It doesn't seem to change it to a different value that it doesn't correspond too. How can I fix it?

1
2
3
4
5
6
7
8
9
10
11
  for (int k = 1; k <= 255; k++)
	{
		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				if (pix[i][j] == k)
				{
					pix[i][j] = num[k-1];
				}
			}
		}	
	}
Why do you think it's not changing? What specific behaviour are you seeing, that differs from the behaviour you expect to see?

I strongly recommend that you step through your code with a debugger. That will allow you to see exactly what's happening.
Topic archived. No new replies allowed.