?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define BUFSIZE 100
#define SIZE 20
char buf[BUFSIZE];
int bufp = 0;
int getch(void){
return (bufp > 0) ? buf[--bufp] : getchar();
}
void ungetch(int c){
if(bufp >= BUFSIZE){
printf("Ungetch! Too many characters!\n");
}
else{
buf[bufp++] = c;
}
}
int getfloat(float *pn){
int c, sign, t;
float p;
while(isspace(c = getch()))
;
if(!isdigit(c) && c != EOF && c != '+' && c != '-'){
ungetch(c);
return 0;
}
sign = (c == '-') ? -1 : 1;
if(c == '+' || c == '-'){
c =getch();
}
for(*pn = 0.0; isdigit(c); c = getch()){
*pn = *pn * 10.0 + (c - '0');
}
if(c == '.'){
c = getch();
}
for(p = 10.0; isdigit(c); c = getch(), p *= 10.0){
*pn += (c - '0') / p;
}
*pn *= sign;
if(c != EOF){
ungetch(c);
}
return c;
}
int main(){
int n;
float arr[SIZE];
for(n = 0; n < SIZE && getfloat(&arr[n]) != EOF; n++);
for(int i = 0; i < n; i++){
printf("%f ", arr[i]);
}
printf("\n");
system("pause");
return 0;
}