Answers for "how to check empty string in c"

C
1

how to denote an empty string in c

#include <stdio.h>
#include <string.h>

int main()
{
    char empty[5] = { '' };
    char null[5];

    if( strcmp(empty,null)==0 )
        puts("Strings are the same");
    else
        puts("Strings are not the same");

    return(0);
}
Posted by: Guest on July-06-2020
0

how to check if a string pointer is empty in c

char *c = "";
if ((c != NULL) && (c[0] == '')) {
   printf("c is emptyn");
}
Posted by: Guest on April-20-2021

Code answers related to "how to check empty string in c"

Code answers related to "C"

Browse Popular Code Answers by Language