I'm not sure if it's strcmp or just the function itself but something isn't working. Here's the code in the main function.
double findLow(const char* date, const Weather *data, int dataSize) {
int i, o;
for (i = 0; i < dataSize; i++) {
o = strcmp(data[i].date(), date); //testing
cout << o << ' ' << data[i].date() << date << endl; //testing
if (strcmp(data[i].date(),date) == 0)
return data[i].low();
}
return 0.0;
}
Here's the code for the date() function(public member function).
const char* Weather::date() const {
return _dateDescription;
}
For some reason the strcmp function will return 1 even if the strings match. dateDescription is a C-style string of 7 characters and the data[i].date() attempts to find the date in the same format as dateDescription.
Also the cout will not show the data[i].date()
EDIT: When I run the full code it looks like this:
Days of Weather: 3
Enter date: Oct/1
Enter high: 15
Enter low : 10
Enter date: Nov/13
Enter high: 10
Enter low : 1.1
Enter date: Dec/15
Enter high: 5.5
Enter low : -6.5
Weather report:
Date high low
======================
Oct/1_______15.0__10.0
Nov/13______10.0___1.1
Dec/15_______5.5__-6.5
Enter the date you are looking for: Nov/13
1 Oct/15
1 Nov/13
1 Dec/15
Low temperature: 0.0(meant to show the low temp of the date requested)
The one that isn't showing is the date variable from what I tested. Paste of the full code