I've trying to allocate an unsigned char**
using calloc:
newmatriz = (unsigned char**) calloc(width, sizeof(unsigned char));
for (j=0 ; j < width; j++)
{
if (newmatriz[j]=(unsigned char*)calloc(witdh, sizeof(unsigned char)) == NULL){
printf("Memory allocation error. Exit program\n");
exit(1);
}
}
for (i=0;i<width;i++)
{
for(j=0;j<width;j++)
{
newmatriz[i][j] = 0;
}
}
But I get segmentation fault when I'm trying to acces the pos [i][j]
Is problem be related to the use int as iterator?