Simple problem with a list!
-
Hi people, I've got an If statement in my code that needs to check the last element of a list. Like follows: if (Remainder == 1 && TesterIterator != Mersenne.end()) This doesn't work the way I would like because the .end() command takes you to one element past the end of the list :'(. I would like to construct an if statement that would like to go to the last element minus one. This is one that I tried but it didn't work :( if (Remainder == 1 && TesterIterator != (Mersenne.end()--)) Does anyone have any ideas? I am very appreciative for all your help in advance. Michael :)
-
Hi people, I've got an If statement in my code that needs to check the last element of a list. Like follows: if (Remainder == 1 && TesterIterator != Mersenne.end()) This doesn't work the way I would like because the .end() command takes you to one element past the end of the list :'(. I would like to construct an if statement that would like to go to the last element minus one. This is one that I tried but it didn't work :( if (Remainder == 1 && TesterIterator != (Mersenne.end()--)) Does anyone have any ideas? I am very appreciative for all your help in advance. Michael :)
Hi, try like this. if (Remainder == 1 && TesterIterator != (Mersenne.end()-1))
Thanks and Regards. SANTHOSH V
-
Hi, try like this. if (Remainder == 1 && TesterIterator != (Mersenne.end()-1))
Thanks and Regards. SANTHOSH V
Thank you very much