Currently working on a snippet to input variables in which a user changes a text file to be used later. Storing these in an array, and later referencing them for some openGL.
The input text file looks something like this.
something = 18.0;
something else = 23.4;
... 6 lines total
//the variable of type ifstream:
ifstream patientInput(".../Patient1.txt");
double n[6]= {0.0,0.0,0.0,0.0,0.0,0.0};
register int i=0;
string line;
//check to see if the file is opened:
if (patientInput) printf("Patient File Successfully Opened.\n");
else printf("Unable to open patient file\n");
while(!patientInput.eof())
{
getline(patientInput,line);
char *ptr, *buf;
buf = new char[line.size() + 1];
strcpy(buf, line.c_str());
n[i]=strtod(strtok(buf, ";"), NULL);
printf("%f\n",n[i]);
i++;
}
//close the stream:
patientInput.close();
Right now it is saving all the values in the array as initialized but not overwriting them later, as it should when I am breaking the lines into the tokens. Any help is appreciated.