Check if the first character is '\0'. You should also probably check if your pointer is NULL.

char *c = "";
if ((c != NULL) && (c[0] == '\0')) {
   printf("c is empty\n");
}

You could put both of those checks in a function to make it convenient and easy to reuse.

Edit: In the if statement can be read like this, "If c is not zero and the first character of character array 'c' is not '\0' or zero, then...".

The && simply combines the two conditions. It is basically like saying this:

if (c != NULL) { /* AND (or &&) */
    if (c[0] == '\0') {
        printf("c is empty\n");
    }
}

You may want to get a good C programming book if that is not clear to you. I could recommend a book called "The C Programming Language".

The shortest version equivalent to the above would be:

if (c && !c[0]) {
  printf("c is empty\n");
}
Answer from codemaker on Stack Overflow
๐ŸŒ
Quora
quora.com โ€บ How-do-I-check-if-a-char-array-is-empty
How to check if a char array is empty - Quora
Answer (1 of 10): Alan gave good answer but let me extend a bit. What empty char array means? Let me use C++ array (vector) class to explain. [code]std::vector String; [/code]In C world this is something like: [code]char* pString = NULL; // non allocated, zero sized array pString = (c...
Discussions

Empty value detection for char* type variable
Hi all, I just simply want to detect whether a char * variable is empty or not. For example, char* token =""; If( token != '\0' ){ Serial.println("okay"); }else{ Serial.println("Something is wrong!!!!"); } But it will alwasy print "okay". What's happening now here? More on forum.arduino.cc
๐ŸŒ forum.arduino.cc
19
0
September 20, 2022
c++ - how to check const char* values one by one - Stack Overflow
I have a const char* variable which takes values from a function that I have wrote. When I write this variable to a file many times it writes nothing. So it must be empty or filled in with space.The strange thing is that in the txt file that I write it changes line every time, when it has value or not.Why is that?Does it mean that the returned value from the function has a \n? how can I check if ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 24, 2017
Check if something wrote into char array - C++ Forum
So now back to my question, how can I check if the array contains after its initialization? Or a different question for this specific code would be, is there a way to find out which string sscanf didnt write into? ... The character arrays haven't been initialized, they'll contain whatever junk is in memory if sscanf has not written to them. Initialize them as empty ... More on cplusplus.com
๐ŸŒ cplusplus.com
February 14, 2012
How to know a char* is an array? - C++ Forum
You should not be checking if p is a nullptr in the loop. If p was not a nullptr to begin with, incrementing it will never make it a nullptr. ___________________________________________________ Example: Note that my signature is const char*. "const" means "read only". This means "pointer to const (read-only) char", which is what the signature needs to be if you ever pass in string literals to the function, because you cannot ... More on cplusplus.com
๐ŸŒ cplusplus.com
๐ŸŒ
Cprogramming
cboard.cprogramming.com โ€บ c-programming โ€บ 59741-how-check-if-char*-empty-null.html
How to check if char* is empty or null??
December 14, 2004 - 0x00951d80 " " 32 ' ' ...bearing in mind the Visual Studio C++ IDE watch dialog. I would have thought these values indicate emptiness, is that not so? Last edited by earnshaw; 12-15-2004 at 04:16 AM. ... It would help if we could see a bit more of the code. Perhaps you're confused on terminology. ... char *s = NULL; /* create a pointer, and make it point to NULL (ie: nothing) */ If you do not initialize a pointer, it does not by default point to null, it points some place randomly, which will more often than not cause you problems.
๐ŸŒ
Arduino Forum
forum.arduino.cc โ€บ projects โ€บ programming
Empty value detection for char* type variable - Programming - Arduino Forum
September 20, 2022 - Hi all, I just simply want to detect whether a char * variable is empty or not. For example, char* token =""; If( token != '\0' ){ Serial.println("okay"); }else{ Serial.println("Something is wrong!!!!"); } But it wiโ€ฆ
๐ŸŒ
Quora
quora.com โ€บ Whats-the-simplest-way-to-check-whether-a-char-array-is-null-in-C++
What's the simplest way to check whether a char array is null in C++? - Quora
Answer (1 of 4): As Davidโ€™s answer explains โ€” it is important to distinguish whether you are checking values in an array, or checking if a label has allocated storage. You have to have storage to store anything. Sounds dumb, and circular, but believe me it is the number one newbie mistake in C a...
๐ŸŒ
Cplusplus
cplusplus.com โ€บ reference โ€บ cctype โ€บ isblank
Cplusplus
Character to be checked, casted to an int, or EOF. A value different from zero (i.e., true) if indeed c is a blank character.
๐ŸŒ
Programiz
programiz.com โ€บ cpp-programming โ€บ library-function โ€บ cctype โ€บ isblank
C++ isblank() - C++ Standard Library
The isblank() function checks if ch is a blank character or not as classified by the currently installed C locale.
Find elsewhere
๐ŸŒ
Reactgo
reactgo.com โ€บ home โ€บ how to check if a string is empty in c
How to check if a string is empty in C | Reactgo
March 8, 2023 - To check if a given string is empty or not, we can use the strlen() function in C. The strlen() function takes the string as an argument and returns the total number of characters in a given string, so if that function returns 0 then the given ...
๐ŸŒ
LinuxQuestions.org
linuxquestions.org โ€บ questions โ€บ programming-9 โ€บ how-to-return-empty-char-*-750700
How to return empty char * ?
August 27, 2009 - Hi: Here is my code: Code: char * func1(){ ... ... return ""; } This code give me warning "deprecated convertion from string to char *
๐ŸŒ
Quora
quora.com โ€บ How-do-you-initialize-char*-to-an-empty-string-in-C
How to initialize char* to an empty string in C - Quora
Yes, โ€œ1 byteโ€ can itself be different sizes on different platforms, but itโ€™s at least 8 bits as per the modern C standard, and on modern, non-esoteric hardware (such as GPUs), it will be exactly 8 bits. ... This helps us sort answers on the page. ... There are two common patterns depending on whether you want a mutable buffer or a pointer to an existing empty string literal. 1) Mutable buffer (recommended when you will write into it) Allocate or declare storage and set the first byte to NUL: ... Point to the static empty string: const char s = ""; // points to read-only "" (do not modify) or (less correct) char s = ""; // allowed by some compilers but modifyi
๐ŸŒ
Cplusplus
cplusplus.com โ€บ forum โ€บ general โ€บ 61898
Check if something wrote into char array - C++ Forum
February 14, 2012 - So now back to my question, how can I check if the array contains after its initialization? Or a different question for this specific code would be, is there a way to find out which string sscanf didnt write into? ... The character arrays haven't been initialized, they'll contain whatever junk is in memory if sscanf has not written to them. Initialize them as empty strings and you simply need to check if the first character is null,
๐ŸŒ
Cplusplus
cplusplus.com โ€บ forum โ€บ beginner โ€บ 272053
How to know a char* is an array? - C++ Forum
In other words, use nullptr when you're making a comparison with a pointer, and use '\0' when making a comparison with a char. In bother cases, you can also just do if (thing) instead of if (thing != '\0'), as it means the same thing, but the latter is a bit more explicit. ... I thought nullptr and '/0' were the same thing? side note on this: zero is defined in c++ as a constant in a dozen + places.
๐ŸŒ
Cplusplus
cplusplus.com โ€บ forum โ€บ beginner โ€บ 248142
Is there problem to declare an empty char array?
December 28, 2018 - You could try initializing your array like this: char c[] = {}; and you will notice that you will get an error. consider char c[6]; cin >> c; And you type in 'hello' c would have { 'h', 'e', 'l', 'l', 'o', '\0'} as elements character arrays must always have null characters.
๐ŸŒ
Arduino Forum
forum.arduino.cc โ€บ projects โ€บ programming
How to check if a char array is blank (or at least 20 ?)<< SOLVED>> - Programming - Arduino Forum
January 21, 2022 - This is a small test sketch : I only want to print these lines if they contain anything: Would anyone please assist me. Many thanks in advance. char line0 [19]; char line1 [19]; char line2 [19]; char line3 [19]; void setup() { Serial.begin(9600); while (!Serial); // wait for serial connection ...
๐ŸŒ
Experts Exchange
experts-exchange.com โ€บ questions โ€บ 26916639 โ€บ Replace-char-in-C-including-empty-char.html
Solved: Replace char in C (including empty char) | Experts Exchange
March 28, 2011 - So, in the case where it fails, is replace_str NULL, or does it point to a '\0' character ? Or something else ? In other words, how do you call this function when it fails ? ... a few things that are wrong: 1. the sizeof(char) should be multiplied with (strlen(in_string) + 1) and not only with 1. like in math the multiplication was done before addition if not forced otherwise by setting parantheses.