コードをコンパイルすると、3 つの警告が表示されます。
warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int *’
warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int *’
warning: format ‘%hhu’ expects argument of type ‘int’, but argument 3 has type ‘unsigned char *’
コードは次のとおりです。
typedef struct
{
int c;
int l;
unsigned char **matrizPixels;
} PGM;
void salvaPGM(PGM *img, char* saida)
{
int i,j;
FILE *arq;
arq = fopen(saida,"w");
fprintf(arq,"P2\n");
fprintf(arq,"%d ", &img->c);
fprintf(arq,"%d ", &img->l);
fprintf(arq,"255\n");
for(i = 0; i++; i < img->l )
{
for (j = 0; j++; j < img->c)
{
fprintf(arq,"%hhu ",&img->matrizPixels[i][j]);
}
fprintf(arq,"\n");
}
fclose (arq);
}