The shortest way to do that would be:
do {
// Something
} while (*url);
Basically, *url
will return the char at the first position in the array; since C strings are null-terminated, if the string is empty, its first position will be the character '\0'
, whose ASCII value is 0
; since C logical statements treat every zero value as false
, this loop will keep going while the first position of the string is non-null, that is, while the string is not empty.
Recommended readings if you want to understand this better: