How to check if C string is empty

后端 未结 12 1150
一个人的身影
一个人的身影 2021-01-30 19:41

I\'m writing a very small program in C that needs to check if a certain string is empty. For the sake of this question, I\'ve simplified my code:

#include 

        
12条回答
  •  后悔当初
    2021-01-30 20:45

    If you want to check if a string is empty:

    if (str[0] == '\0')
    {
        // your code here
    }
    

提交回复
热议问题