Read file into array

Pages: 12
I have another problem tho.
I have a function that allows the user to enter usrName and date and then it checks the array and if the name and the date is the same as in the array all the info in that array slot is presented.
when I do that I can see item 1 and item 2 but not item 0.
here is the code
1
2
3
4
5
6
7
8
9
10
void DH::findOld(string date,string usrName)const
{
	for(int i=0;i<this->nrOfDiets;i++)
	{
		if(date==this->dh[i]->getDate() && usrName==this->dh[i]->getUsrName())
		{
			this->dh[i]->show(i);
		}
	}
}

I think there maybe is something wrong with the name and the date that is sent to the array because when i remove the if-statement everything is presented.
Last edited on
That's not that bad. Though if you are interested in a way to convert strings to numbers:
1
2
3
4
5
6
7
8
9
std::string my_str;
int my_int;
std::stringstream ss;
ss<<my_str;
if(ss>>my_int) {
    // conversion worked (works like cin)
} else {
    // conversion failed
}
Topic archived. No new replies allowed.
Pages: 12