salve a tutti,
ho un problema con l'input in c vorrei che quando un utente utilizzasse il programma potesse inserire solo numeri e non lettere come potrei fare ? grazie
questo è il codice sorgete a cui devo applicare la restrizione in input:
codice:
#include<stdio.h>
#include <stdlib.h>
#define SIZE 4
int main (int argc,const char*argv[]){
float array[SIZE];
int x;
float q;
float m;
printf("inserisci coef. angolare\n");
scanf("%f",&m);
printf("inserisci q\n");
scanf("%f",&q);
printf("%s%13s\n","Elemento","Valore");
for(x=0;x<=SIZE-1;x++){
array[x]=m*x+q;
}
for(x=0;x<=SIZE-1;x++){
printf("%8d%13.2f\n",x,array[x]);
}
return 0;
system("pause");
}