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

Copychar *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:

Copyif (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:

Copyif (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??
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.
🌐
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...
🌐
Cplusplus
cplusplus.com › reference › cctype › isblank
Cplusplus
In C++, a locale-specific template version of this function (isblank) exists in header <locale>. Compatibility note: Standardized in C99 (C++11). ... 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.
🌐
Sabe
sabe.io › blog › c-check-string-empty
How to Check if a String is Empty in C | Sabe
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....
🌐
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 ...
🌐
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])) ...
Find elsewhere
🌐
C For Dummies
c-for-dummies.com › blog
Null Versus Empty Strings | C For Dummies Blog
#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 ?) - 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…
🌐
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.
🌐
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 - In C, we can check if a string is empty using various methods, such as checking the first character, using the strlen() function, or comparing it with an empty string.
🌐
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?
October 12, 2016 -

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!

🌐
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 - #include <stdio.h> #include <stdbool.h> bool isCharArrayEmpty(char arr[], int size) { for (int i = 0; i < size; i++) { if (arr[i] != '\0') { return false; // 如果数组中有一个元素不是空字符,则返回false } } return true; // 如果数组中所有元素都是空字符,则返回true } int main() { char arr1[] = {'\0', '\0', '\0'}; char arr2[] = {'a', 'b', 'c'}; if (isCharArrayEmpty(arr1, sizeof(arr1)/sizeof(arr1[0]))) { printf("arr1 is empty\n"); } else { printf("arr1 is not empty\n"); } if (isCharArrayEmpty(arr2, sizeof(arr2)/sizeof(arr2[0]))) { printf("arr2 is empty\n"); } else { printf("arr2 is not empty\n"); } return 0; } In the above code, the isCharArrayEmpty function is used to check if a char array is empty.
🌐
CodeVsColor
codevscolor.com › c program to check if a string is empty or not - codevscolor
C program to check if a string is empty or not - CodeVsColor
June 14, 2021 - Else, it is not. To get the length of a string, we can use the strlen method. This method takes one string as its argument and returns the length for that string. If the return value of this function is 0, then the string is empty.
🌐
Iditect
iditect.com › program-example › how-to-check-if-c-string-is-empty.html
How to check if C string is empty
The simplest way to check if a C string is empty is to see if the first character is the null terminator.