CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
10
Task/Empty-string/C/empty-string.c
Normal file
10
Task/Empty-string/C/empty-string.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* assign an empty string */
|
||||
const char *str = "";
|
||||
/* to test a null string */
|
||||
if (str) { ... }
|
||||
/* to test if string is empty */
|
||||
if (str[0] == '\0') { ... }
|
||||
/* or equivalently use strlen function */
|
||||
if (strlen(str) == 0) { ... }
|
||||
/* or compare to a known empty string, same thing. "== 0" means strings are equal */
|
||||
if (strcmp(str, "") == 0) { ... }
|
||||
Loading…
Add table
Add a link
Reference in a new issue