Ciao a tutti![]()
Ho questo semplice pezzo di codice che non funziona...
Voglio semplicemente leggere delle righe di testo da tastiera e stamparle
codice:#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define MAX 80 int leggi_video(char testo[][MAX]); void stampa_matrice(char matrice[][MAX], int row); main() { char testo[MAX][MAX]; int righe; printf("Inserisci delle parole.\n"); righe=leggi_video(testo); stampa_matrice(testo, righe); return 0; } int leggi_video(char matrice[][MAX]) { int i=0; char stringa[MAX+1]; while(fgets(stringa, MAX+1, stdin)!= NULL) { stringa[strlen(stringa)-1]='\0'; strcpy(matrice[i], stringa); i++; } return(i); } void stampa_matrice(char matrice[][MAX], int row) { int i; for(i=0; i<row; i++) printf("%s\n", matrice[i]); }![]()

Rispondi quotando
