I am having some difficulties in understanding the condition of the while
loop given below:
int main()
{
char s[]="Let's Get it Started";
int i=0;
while(s[i]!=0)
{
//do something
++i
}
}
I know that string is stored with the last character as \0
which has the ASCII value as 0
. In the while
loop, it is comparing the value of the particular characters of the array. So when it reaches \0
condition would be like
'\0' != 0 // I guess this is also true
So isn't this an infinite loop?