The program doesnt run, but i dont understand why..
I mean, is there any restriction for using a double for loop with iterators ? Or what could cause it to crash ?
EDIT: @Peter87, thanks, I'll try that now.
EDIT2: Seems that my vector doesnt contain value '0', at least I think it doesnt.
// Parts of the code where "sir" appears
//code...
vector<Lung> sir;
sir.reserve(10);
//code...
ifstream in("prime1.in");
in >> N;
for (short i = 1; i <= N; ++i)
{
in >> X;
sir.push_back(X);
}
//code...
// Here comes the code I wrote in the post.
The sir.push_back(X); can be called for a maximum of 9 times (that is specified in the problem data -- this is a longer exercise given at a contest). If it is less than 9, does that mean the unused elements are equal to 0 ? (From my beginner knowledge about STL, I know that sir.reserve(10); doesnt initialize anything, it just reserves the space for 10 variables/elements)
No, I don't see why you would't use a double loop, or even a triple or quadruple loop, it doesn't matter! Iterators are compleatly regular varibables, only the have type "whatever::iterator"
@SIK: I have added the check, but it still crashes. Code returned:
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Terminated with return code 3.
------------------------------------------------------------------------------
Found the error... I have reserved 1.000.000.000 elements for the vector 'numere'.
That was why it crashed.
Thanks for all the help given, and sorry for wasting your time.
Have a nice day.
------------------------------------------------------------------------------