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
๐ŸŒ
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 - It is only empty if it doesnt contain a character (except \0), if the value is " " then it contains a space, which is a character. Check if its NULL, Empty (only '\0'), if its not either see if it contains other characters besides a white space.
Discussions

How to check if C string is empty - Stack Overflow
Since C-style strings are always terminated with the null character (\0), you can check whether the string is empty by writing ... 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! ... Sign up to request clarification or add additional context in ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
c - Best way to check if a character array is empty - Stack Overflow
There's certainly nothing wrong with this approach in this case, so you may as well use it. The third method doesn't check whether a character array is empty; it ensures that a character array is empty. ... The second one is fastest. Using strlen will be close if the string is indeed empty, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to check if String is empty in C - Stack Overflow
Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I have a void function which take the string from a global variable and prints them. The problem is that the void function prints a message/does stuff even if the string is empy. so if the global variable is empt it just prints "message is:" i only want to do something if the string has characters. what i want to do is to check ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
c - How can I check if a char * is empty? - Stack Overflow
What is "empty" ? Initialize it to NULL in the beginning and check *name == NULL. Yet it looks like XY-problem to me. This whole approach is going to give you troubles in the future. Eugene Sh. โ€“ Eugene Sh. 2018-06-01 13:47:20 +00:00 Commented Jun 1, 2018 at 13:47 ยท strlen works by counting the number of characters up untill the null char '\0' You could check to see if ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Sabe
sabe.io โ€บ blog โ€บ c-check-string-empty
How to Check if a String is Empty in C - Sabe.io
March 19, 2022 - CLIKE#include <stdio.h> #include ... 0; } Another way you can check if a string is empty is to check if the first character of the string is a null character....
๐ŸŒ
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.
๐ŸŒ
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 ...
Find elsewhere
๐ŸŒ
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...
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ c-programming โ€บ how-to-check-if-a-string-is-empty-in-c
How to Check if a String is Empty in C - Examples
February 21, 2025 - If the length is zero, we print "The string is empty.". Otherwise, we print "The string is not empty.". The string is empty. In this example, we compare the string with an empty string using strcmp() from string.h. ... #include <stdio.h> #include ...
๐ŸŒ
Silicon Cloud
silicloud.com โ€บ home โ€บ how to determine if a char array is empty in c language?
How to determine if a char array is empty in C language? - Blog - Silicon Cloud
March 28, 2024 - In C language, to determine if a char array is empty typically means checking if all elements in the array are null characters (โ€˜\0โ€™).
๐ŸŒ
Programiz
programiz.com โ€บ cpp-programming โ€บ library-function โ€บ cctype โ€บ isblank
C++ isblank() - C++ Standard Library
The isblank() function returns non zero value if ch is a blank character, otherwise returns zero. #include <cctype> #include <iostream> #include <cstring> using namespace std; int main() { char str[] = "Hello, I am here."; int count = 0; for (int i=0; i<=strlen(str); i++) { if (isblank(str[i])) ...
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ how to detect an empty string in standard input?
r/C_Programming on Reddit: How to detect an empty string in standard input?
February 4, 2017 -

Im not sure if im correct in calling it an empty string but i thought it would be.

#include "stdio.h"
#include "string.h"
#include "stdlib.h"

int main(void)
{
	char input[136];
	char partOne[6];
	char partTwo[128];
	fgets(input, 136, stdin); // Now i input "Hello " or "Hello"
	sscanf(input, "%5s %127s", partOne, partTwo);
	if(!strcmp(partTwo, ""))
		printf("%s\n", "YES");
	return 0;
}

if I input "Hello " or "Hello" I want to detect that the char array partTwo has an empty string (i don't know what else to call it) but since the check fails then I think its not an empty string so what is it?

If I input "Hello" or "Hello " what is the value of partTwo so I can test for it using strcmp

Thank you!

๐ŸŒ
C For Dummies
c-for-dummies.com โ€บ blog
Null Versus Empty Strings | C For Dummies Blog
August 12, 2017 - #include <stdio.h> #include <string.h> int main() { char empty[5] = { '\0' }; char null[5]; if( strcmp(empty,null)==0 ) puts("Strings are the same"); else puts("Strings are not the same"); return(0); } Array empty[] at Line 6 is created as an empty string. It has a single element, a null character.
๐ŸŒ
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 ...
๐ŸŒ
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 โ€บ 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...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-isblank-in-cpp
What is isblank() in C++?
We use the isblank() function in C++ to determine if a given character is a blank character.