Since C-style strings are always terminated with the null character (\0), you can check whether the string is empty by writing

do {
   ...
} while (url[0] != '\0');

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.

Hope this helps!

Answer from templatetypedef on Stack Overflow
๐ŸŒ
Cprogramming
cboard.cprogramming.com โ€บ c-programming โ€บ 117372-check-if-string-null.html
Check if string is null
Can you tell me how to check if a string is null in C? I tried p != '\0' doent seem to wrk though! It all depends on what you mean, and what p is declared as. That looks like an empty string check to me.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ how do i compare a string to null in c++?
r/learnprogramming on Reddit: How do I compare a string to NULL in C++?
September 27, 2019 -

I need to simply check if an object in a string vector is null or not:

std::vector<string> vliwSlots;
//Some inserts...
string vliwSlot = vliwSlots.at(i); //in a for loop
if(vliwSlot != NULL){ //error on this line
    //Do stuff
}

When I compile this I get the following error at :

no match for โ€˜operator!=โ€™ (operand types are โ€˜std::__cxx11::string {aka std::__cxx11::basic_string<char>}โ€™ and โ€˜long intโ€™)

It seems it thinks NULL is a long int. How the heck do I check if a string is null?

๐ŸŒ
C For Dummies
c-for-dummies.com โ€บ blog
Null Versus Empty Strings | C For Dummies Blog
You must compare the two: Create an empty string or null string as a sample, then use the strcmp() function to compare them. A null string compares to another null string, and an empty string to an empty one. #include <stdio.h> #include <string.h> int main() { char empty[5] = { '\0' }; char ...
๐ŸŒ
Sabe
sabe.io โ€บ blog โ€บ c-check-string-empty
How to Check if a String is Empty in C
March 19, 2022 - Therefore, if the length of the string is 0, then the first character of the string is a null character. ... CLIKE#include <stdio.h> #include <string.h> int main() { char string[] = ""; if (string[0] == '\0') { printf("String is empty"); } else ...
๐ŸŒ
Quora
quora.com โ€บ How-do-I-check-if-a-string-is-empty-in-C
How to check if a string is empty in C - Quora
Answer (1 of 10): Many of the answers I have seen here are well-intentioned, but also use outdated methods. Assuming that all strings are ANSI formatted is an incomplete answer. Well, first of all, C does not have a string type. A string in C is essentially a set of characters in contiguous mem...
๐ŸŒ
GameDev.net
gamedev.net โ€บ forums โ€บ topic โ€บ 421554-c-how-do-i-check-if-a-stdstring-is-null โ€บ 3807807
[C++] How do I check if a std::string is NULL? - General and Gameplay Programming - GameDev.net
October 30, 2006 - However, it seems that std::string has an overriden operator == which doesn't allow me to check if it is null. (If could try void setName(std::string* newName), but thet setName("name") wouldn't work). Any advice would be appreciated! ... if (newName.empty()) this->name = "Default"; That will work of you call setName(""), you can't call setName(NULL), unless you used a pointer as an argument, but what you really should use is a constant reference instead of passing by value.
๐ŸŒ
Cplusplus
cplusplus.com โ€บ reference โ€บ string โ€บ string โ€บ empty
std::string::empty
Returns whether the string is empty (i.e. whether its length is 0). This function does not modify the value of the string in any way. To clear the content of a string, see string::clear.
Find elsewhere
๐ŸŒ
tutorialpedia
tutorialpedia.org โ€บ blog โ€บ how-to-check-if-c-string-is-empty
How to Check if a C String is Empty: Practical Example for User Input Loop Termination โ€” tutorialpedia.org
By defining "empty" as a string with only the null terminator ('\0'), we can use simple methods like checking the first character (str[0] == '\0'), strlen(str) == 0, or strcmp(str, "") == 0.
๐ŸŒ
Quora
quora.com โ€บ How-do-you-check-for-an-empty-string-and-null-character-in-the-C-programming-language
How to check for an empty string and null character in the C# programming language - Quora
Answer: You first have to explain what โ€œermptyโ€ means for you. However, i always use [code ]String.IsNullOrEmpty[/code] if i want to know if the string is either null or an empty string(โ€œโ€), so contains no letters, not even white-spaces. You also can use [code ]String.IsNullOrWhiteSpac[/code]`. T...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-check-if-a-string-is-null-or-empty-in-c-sharp
How to check if a string is null or empty in C#
IsNullOrEmpty() returns true if the input is an empty string. In C#, this is a zero length string (""). ... string str1 = ""; string str2 = String.Empty; Console.WriteLine(String.IsNullOrEmpty(str1)); // True Console.WriteLine(String.IsNull...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c++ โ€บ check-if-string-is-empty-in-cpp
How to Check if a String is Empty in C++? - GeeksforGeeks
July 23, 2025 - To check for an empty string we can use the std::string::empty() function because what the empty function does is it checks for the length of a string and if the string is empty, it returns true, otherwise, it returns false.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-check-for-input-string-validity-Check-if-the-input-string-is-null-if-it-is-return-null-in-C-language
How can I check for input string validity? Check if the input string is null; if it is, return null in C language.
Answer (1 of 4): [code]const char* is_something(const char* str) { if(!str || !*str) return NULL; return str; } [/code]A string in C is a null -terminate sequence of character. A null string is a string containing just a terminator. And since string are passed around as pointer to the sequence...
๐ŸŒ
UiPath Community
forum.uipath.com โ€บ help
How to check if a string is not empty? - Help - UiPath Community Forum
March 3, 2020 - Hi all, Iโ€™m reading a text from certain position and entering into a do while loop to work on some actions. The text will contain different strings each time and to perfom these activies inside the do while loop the teโ€ฆ