So I need to get the data from the text file into each member of the struct.
The text file format is:
3
200703270345 C74.54
200703270345 C74.54
200703270345 C74.54
3 being the number of entries.
2007 - year
03 - month
27 - day
0345 - time
c74.54 - temp
I'm gettin the error invalid conversion from 'int' to 'char*' and I have no idea what I did wrong.
im confused as to what the "r" refers too in line 25 of your code.
I compiled and ran it then it said the program has stopped working No idea what i did wrong.
Okay. 2 problems with the original code (as I can see):
1st is what rishabhagl mentioned. You cannot create an array like you did on line 28.
Use a vector to solve this:
1 2 3 4 5 6 7 8
#include <vector>
// Code here
// READINGS BioData[d]; // REPLACED
vector <READINGS> BioData(d); // this will create a dynamic C++ array (called a vector)
// The d in the () will reserve space for d elements.
// Access elements with [] as you were doing.
The second is that error you're getting. You are attempting to read from the file using the .getline() method. This method returns a char* array which cannot be magically converted to an integer as you are trying to do.
My only suggestion here is use std::string and std::getline() to read the entire file's line then split the data and use std::stringstream to convert to integers. Its either that or you need to add some white space in your text file between the date numbers and the time numbers so its smaller than an unsigned integer.