Quando eseguo il programma si blocca ma non capisco il perchè!codice:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <math.h> void creamatrice(float **M, int COLUMNS, int ROWS); void StampMatrix(float **M, int COLUMNS, int ROWS); void InserisciDaTastiera(char *stringa, int Max); main() { float **M; char *str; char c; int COLUMNS, ROWS; printf("Inserisci il numero di righe:\n"); InserisciDaTastiera(str, 100); ROWS=atoi(str); printf("NUM RIGHE: %d\n", ROWS); printf("Inserisci il numero di colonne:\n"); InserisciDaTastiera(str, 100); COLUMNS=atoi(str); printf("NUM COLONNE: %d\n", COLUMNS); creamatrice(M, COLUMNS, ROWS); StampMatrix(M, COLUMNS, ROWS); system("PAUSE"); } void creamatrice(float **M, int COLUMNS, int ROWS){ int i, j, k; M = (float**)calloc(ROWS,sizeof(float*)); for (i=0; i<ROWS; i++) M[i] = (float*)calloc(COLUMNS,sizeof(float)); for (k=0; k<ROWS; k++) { for (j=0; j<COLUMNS; j++) { // (float)rand()/(float)30 M[i][j]=1.5; } } } /*========================================== * Function per stampare una matrice *========================================*/ void StampMatrix(float **M, int COLUMNS, int ROWS) { int i, j; for ( i=0; i < ROWS; i++ ) { printf("%d", i); for ( j=0; j < COLUMNS; j++ ) { printf(" | ", M[i][j]); } } } /* ============================================= ** Function per leggere una stringa di caratteri ** da tastiera ** ---------------------------------------------*/ void InserisciDaTastiera(char *stringa, int Max) { int i; fgets(stringa, Max, stdin); for ( i=0; stringa[i] < 0 || stringa[i] > 31; i++); stringa[i]=0; fflush(stdin); }
Grazie anticipatamente

Rispondi quotando