Io avrei pensato di fare una funzione con getch() e atof()
sempre che si possa usare getch() che è una funzione non standard .
ti posto un esempio :
codice:#include<stdio.h> #include <stdlib.h> #define SIZE 4 float inputfloat(); int main (int argc,const char*argv[]){ float array[SIZE]; int x; float q; float m; printf("inserisci coef. angolare\n"); m=inputfloat(); printf("inserisci q\n"); q=inputfloat(); 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]); } system("pause"); } float inputfloat() { char temp; char numero[20]; char punto =0; int i=0; do { temp=getch(); if ((temp>=48 && temp<=57)||temp==46)//se il carattere è un numero o un punto . { if(temp==46 && punto==0) // se è . { punto=1; putchar(temp); numero[i++]=temp; } if(temp!=46) { putchar(temp); numero[i++]=temp; } } }while(temp!=13); numero[i]=0; printf("\n"); return (float) atof(numero); }

Rispondi quotando