#include "header.h" //Preforms input int collectinput(double *inputs) { int top=0;//Top of the inputed float array; where's next? char inputchar; //Store the output of "getchar". char buffer[100]; //Declare a buffer to store our float-to-be int buffpoint=0; //Where are we in this buffer? Init: at start. inputchar='0'; //Set input as a leading 0. while(feof(stdin)==0 ) //While we haven't ran out of reading material { buffer[buffpoint]=inputchar;//Stick the inputed value in buffer buffpoint++; //Increment the buffer point if (isspace(inputchar)) //if it's whitespace, the value is done { //THEN the value is processed! buffer[buffpoint]=(char)NULL;//Null terminate the string //That caused a warning, but it can be ignored. inputs[top]=atof(buffer);//argument to float it! top++; //Note we've stuck it in the array. buffpoint=0;//Reset the buffer! //Due to null-termination, we don't have to clear it. } if (top==max) //if we are at the input array's maxima { return top; //Abort and go to the next step } //This function will be called again from main to finish inputchar=getchar(); //ELSE GET ANOTHER CHARACTER and REPEAT! } return top; //oh, we're done. Return how big the input array got. }