Check if a character array is empty in C language.

In C language, you can determine if a character array is empty by checking if the first element of the array is ‘\0’. If the first element is ‘\0’, then the character array is considered empty.

Here is an example code:

#include <stdio.h>

int main() {
    char str[100] = ""; // 初始化一个空字符数组

    // 判断字符数组是否为空
    if (str[0] == '\0') {
        printf("字符数组为空\n");
    } else {
        printf("字符数组不为空\n");
    }

    return 0;
}

Running this code will produce the output: “The character array is empty.”

bannerAds