I've been trying to add two 2D arrays together with different element types: red, green and blue that point to a structure. I'm pretty sure the two arrays are read in correctly I just don't think they're added together right...
Code:
RGBArray = (PPMPixel **)malloc(head[1].height*sizeof(PPMPixel*)); //Points to malloc
if((RGBArray == NULL))
{
printf("\tError allocating memory to the array\n");
}
else
{
printf("\tMemory allocated to the PPM array sucessfully\n");
}
for (i=0;i<head[1].height;i++)
{
RGBArray[i] = (PPMPixel *)malloc(head[1].width*sizeof(PPMPixel));
}
for (j=0;j<head[1].height;j++)
{
for (i=0;i<head[1].width;i++)
{
RGBArray[j][i].red = (AddArray1[j][i].red + AddArray2[j][i].red);
RGBArray[j][i].green = (AddArray1[j][i].green + AddArray2[j][i].green);
RGBArray[j][i].blue = (AddArray1[j][i].blue + AddArray2[j][i].blue);
//printf("%d ", RGBArray[j][i].red);
//printf("%d ", RGBArray[j][i].green);
//printf("%d ", RGBArray[j][i].blue);
}
}