How to check if C string is empty

后端 未结 12 1176
一个人的身影
一个人的身影 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:47

    First replace the scanf() with fgets() ...

    do {
        if (!fgets(url, sizeof url, stdin)) /* error */;
        /* ... */
    } while (*url != '\n');
    

提交回复
热议问题