+ 2
Whats wrong in this?
string length without using strlen https://code.sololearn.com/cjqQQ4RhSSzW/?ref=app want to output the total no.of characters like 5 not like 0,1,2,3,4,
7 odpowiedzi
+ 4
Line 8 and 9:
for(i = 0; s[i] !='\0'; ++i);
printf(" %s\nLength of string: %d",s, i);
+ 2
it still doesn't gives the answer 5?
+ 2
or I say it gives same answer just the name of sting ,which I didn't needed anyway
+ 2
Abhay, note the semicolon at the end of line 8, the for loop should terminate on that very line, otherwise, line 9 will be considered as loop body; if we don't have the semicolon at end of line 8.
+ 2
woo thks 😄and all time I thought we don't terminate for Loop with semicolon!!
+ 2
You're welcome Abhay. Also when we put semicolon at end of a loop it means we're creating a loop without a body, but the values in the loop initialization will still change, difference is just the loop doesn't have loop body : )
+ 2
thks for the valuable info,