How to check if C string is empty

后端 未结 12 1152
一个人的身影
一个人的身影 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条回答
  •  -上瘾入骨i
    2021-01-30 20:45

    You can check the return value from scanf. This code will just sit there until it receives a string.

    int a;
    
    do {
      // other code
      a = scanf("%s", url);
    
    } while (a <= 0);
    

提交回复
热议问题