I am writing code to read a PPM file into a struct pixel_type array containing 3 unsigned chars r,g, and b. The code that causes problems looks like this:
struct pixel_type pArray[width][height], *pPtr[width][height];
pPtr[width][height] = &pArray[width][height];
for(h = 0; h < height; h++)
{
for(w = 0; w < width; w++)
{
fscanf(in, "%c%c%c", pPtr[w][h]->r, pPtr[w][h]->g, pPtr[w][h]->b);
}
}
When compiling, I get this message for all 3 "%c"s:
warning:
format â%câ expects argument of type âchar *â, but argument (3,4, or 5) has type âintâ [-Wformat]
What would be the best way to read the pixel values into the struct pixel_type array?
struct pixel_type
{
unsigned char r;
unsigned char g;
unsigned char b;
};