char *str = "Hello";
while (str) {
    printf("%c\n", *str);
    str++;
}

str is array pointer!!!

Here at last (!= Null) gets value of pointer to compare
Pointer value will always have some value
so this will never give as NULL

If we used while (str) as the loop condition, it would be interpreted as
while (str != NULL), which would always be true since str is not a null
pointer. This would result in an infinite loop.

__________________________________________________________________________


char *str = "Hello";
while (*str) {
    printf("%c\n", *str);
    str++;
}

In this updated code, the loop condition while (*str) checks if the character
pointed to by str is non-zero, allowing us to iterate over the string
correctly until we reach the null character.

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: