I’m working on my C++ practice question to prepare for my upcoming test and I’m struggling with a for loop condition that I have never seen before.
for (int i = 0; s[i]; i++)
The string s that has been sent from the main is "Two roofs to fix"
The question is when is the for loop’s condition will become false?
The loop condition becomes false, when the string’s terminating zero
'\0'is hit. (if (0)evaluates to false)Please note: this form of test is a possible error waiting to happen if the string isn’t null terminated.