Jul 7, 2016 at 1:57am UTC
> The problem is most likely activityDistance- I get warnings that tell me it is an unused variable
Simply, just initialize activityDistance with a (0) :
double activityDistance = 0;
Last edited on Jul 7, 2016 at 1:57am UTC
Jul 7, 2016 at 2:02am UTC
I tried that, but the function still isn't activating.
Jul 7, 2016 at 2:05am UTC
void addActivity( string activityType, double activityDistance);
Could you please let us see it?
Jul 7, 2016 at 2:06am UTC
Also, your function main() is also helpful too.
Jul 7, 2016 at 2:09am UTC
addActivity is set within the Private part of a Class, while processData is outside both the Class and the Main function. Could that be related?
Jul 7, 2016 at 2:13am UTC
my main() function goes:
int main()
{
User UserTest;
UserTest.processData("activitydata.csv");
UserTest.getActivityDetails("all", "avg");
return 0;
}
Jul 7, 2016 at 2:41am UTC
Alternating Hoorays and hitheres. The arrays are being filled, but only partly- there are 5 pieces of data in the arrays, while the original file had 10 pieces of information. But the function is clearly being called.
Jul 7, 2016 at 2:48am UTC
So "the function" is addActivity() you are referring to?
Also, how many "Hooray" msg appeared in your program output just now?
Jul 7, 2016 at 2:51am UTC
Lol I mistook "hitheres" for another word. You should separate them with a space.
Jul 7, 2016 at 2:53am UTC
The words appear 6 times each, reading an Excel File that is 11 rows (10 data and one Header.)
Jul 7, 2016 at 2:57am UTC
Can you show us the context of the file activitydata.csv by using notepad?
Jul 7, 2016 at 3:00am UTC
Sorry if this isn't the greatest format to read.
activity, distance
run, 5.3
skierg, 1
erg, 2
run, 7
skierg, 0.54
skierg, 0.34
run, 2
erg, 1
erg, 0.75
run, 9
Jul 7, 2016 at 3:03am UTC
My output for the contents of the Arrays are:
RUN(5.3, 2)
SKIERG (.54)
ERG (2, .75)
Jul 7, 2016 at 3:41am UTC
It returns:
Hooray!
terminate called after throwing an instance of 'std::invalid_argument'
what(): stod
Aborted (core dumped)
I think it tries to convert the text to a double, which won't let it work. Also, that way would leave me unable to read the activityType.
Jul 7, 2016 at 3:56am UTC
If the stod is the curpit try manual debugging
1 2 3
getline(megaFile, distance);
cout << "Type : " << activityType << endl;
cout << "Distance : \"" << distance << "\"" << endl << endl;
Last edited on Jul 7, 2016 at 3:58am UTC
Jul 7, 2016 at 4:00am UTC
Also let us know the output outcome