To check if a string is empty is useful like when user is prompt to input a string, but maybe the user only hit "enter" and didn't type anything, now we get an empty string.
So usually if we get user to input a string, we should check first if it's empty or not. Only if it's not empty then we do things with the string.
Since C-style strings are always terminated with the null character (\0), you can check whether the string is empty in 3 different ways:
1. Check if the first char in the string is '\0':
do {
...
} while (url[0] == '\0');
2. If the string is empty, the string length is 0, but there will be 1 byte in the memory because there is a '\0', so we just need to check if the string length is bigger than 0:
if ((strlen(t)>0) //only if it's not an empty string then will go into the brackets of "if"
{
...
}
3. Alternatively, you could use the strcmp function, which is overkill but might be easier to read:
do {
...
} while (strcmp(url, ""));
Note that strcmp returns a nonzero value if the strings are different and 0 if they're the same, so this loop continues to loop until the string is empty.