Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

2D Arrays: cannot convert from 'int *' to 'int'

$
0
0
I've been working on a program which outputs a PPM pixelmap file after drawing it into a 2D array. I believe I have the idea down and most of it working but I'm running into the following error:

error C2440: '=' : cannot convert from 'int *' to 'int'


The code:
void drawRectangle( int x, int y, int width, int height, int *pixArr[], int rgb[] )
{
	char temp[16];
	int i = 0, j = 0;

	pixArr[i] = new int [resolution[1]];
	for ( i = 0; i < resolution[1]; ++i )
	{
		pixArr[i][j] = new int [resolution[0]];
		for ( j = 0; j < resolution[0]; ++j )
		{
			pixArr[i][j] = new int [3];
			if ( ( j >= x && j <= ( j + resolution[0] ) ) && ( i <= y && i >= ( i - resolution[1] ) ) )
			{
				pixArr[i][j][0] = rgb[0];
				pixArr[i][j][1] = rgb[1];
				pixArr[i][j][2] = rgb[2];
			}
			else
			{
				pixArr[i][j][0] = 0;
				pixArr[i][j][1] = 0;
				pixArr[i][j][2] = 0;
			}
		}
	}
}


The error occurs on Line 9.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>