why my program did not go in infinite loop. I have not used '\0'
for testing string end in while loop, instead of that I have use 0
. Does '\0'
and 0
same in C?
If yes, then if 0
is in the middle of a string, then printf
should end printing the string right there.
e.g. printf("%s", "hello how0 are you")
should print 'hello how'
int main( )
{
char s[ ] = "No two viruses work similarly" ;
int i = 0 ;
while ( s[i] != 0 )
{
printf ( "%c", s[i]) ;
i++ ;
}
}
65 66 67 0
, 65 being the ASCII value of theA
character etc. – Jabberwocky