Alla fine ho fatto a modo mio
Ho semplicemente sostituito la newline col terminatore nella funzione input e poi ho usa printf invece di puts.
Per farla più breve ho fatto una matrice 3x3 invece che 5x5,tanto la pappa è la stessa.
Ecco il codice:
codice:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <time.h>
#include <stdbool.h>
#include <string.h>
char *input(void);
int main(int argc,char **argv)
{
char ***stringmatrix;
int i,j;
stringmatrix=(char***)calloc(3,sizeof(char**));
if(stringmatrix==NULL)
{
printf("Errore, scappa !!!\n");
exit(0);
}
for(j=0;j<3;j++)
{
stringmatrix[j]=(char**)calloc(3,sizeof(char*));
for(i=0;i<3;i++)
{
stringmatrix[j][i]=input();
}
}
for(j=0;j<3;j++)
for(i=0;i<3;i++)
printf("%s",stringmatrix[j][i]);
return 0;
}
char *input(void)
{
char *buffer,*pointer;
buffer=(char*)calloc(100,sizeof(char));
if(buffer==NULL)
{
printf("Errore, scappa !!!\n");
exit(0);
}
fgets(buffer,100,stdin);
pointer=(char*)calloc(strlen(buffer)+1,sizeof(char));
strcpy(pointer,buffer);
pointer[strlen(buffer)-1]='\0';
free(buffer);
return pointer;
}
Anche se poi non ci ho dormito la notte,bella questa proposta Yu