0
[SOLVED] Why does it say that i isn't equal to -1?
Is someone able to explain this to me? int main() { string str; getline(cin,str); int x; x = str.size(); for (int i=x;i!=-1,i--;)
7 odpowiedzi
+ 4
I think there's a mistake. The loop line should look like this:
for(int i=x; i!=-1; i--)
The middle part of the for loop determines the condition that keeps the loop running.
So as soon as i becomes equal to -1, the loop is over.
Was your finishing of the C++ tutorial a while ago? Maybe it is time for a review!
In case I have simply misunderstood your question, please clarify.
Also you might want to add a bit more of the code (the loop body for example), so that we get an idea what this is about.
Also there are more tags you could use, for example 'C++', 'loops' or something else you find fitting for your question.
+ 1
HonFu I think you're right It's time for a review 😂
0
Aaahh I understand now thx dude
0
Yeah that's my bad it was meant to be a semi colon