Ecco tutto il codice.
L'errore riscontrato è : Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) alla riga result[i][j] = (char *)malloc(100 * sizeof(char));
Ps: uso xCode
codice:
int main(int argc, char* argv[]){
/*
* Creo la matrice che ritornerò con i dati
*/
int rows = 10;
int cols = 3;
//Creo le righe
char *** result = calloc(rows, sizeof(char **));
//Creo le colonne
for (int i = 0; i < cols; i++)
{
result[i] = calloc(cols, sizeof(char *));
}
//Carico la matrice
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
result[i][j] = (char *)malloc(100 * sizeof(char));
if (NULL != result[i][j])
{
strcpy(result[i][j], "ciao");
}
}
printf("\n");
}
//Stampo la matrice
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
printf("%s\t", result[i][j]);
}
printf("\n");
}
return 0;
}