Se usassi fgets e poi utilizzo la funzione atoi ? tipo così:
e poi nel main faccio:codice:/* ============================================= ** 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); }
codice:char *str; int var; InserisciDaTastiera(str, 50); var = atoi(str);