c - 'target_tweet'的地址永远不会是NULL!?

标签 c null strcmp

我该如何解决这个警告?它显然阻止我使用 gcc 进行编译。我错过了什么吗?

#include <stdio.h>
#include <string.h>
int main(void) { 

         int MAX_TWEET_SIZE = 32;
         char target_tweet[MAX_TWEET_SIZE];
         int MAX_SIZE = 140
         char tweet[MAX_SIZE];
          int match = 0;

         printf("Enter Target Tweet\n");

         fgets(target_tweet, MAX_TWEET_SIZE, stdin);

         if (target_tweet[0] != '#'){
                         printf ("ERROR\n");
                         return 0;
                 }


         printf("Enter Tweets!\nenter '.' to quit:\n"){

         while (1){
                 scanf("%s", tweet);
                 if (strcmp(tweet, target_tweet == 0)){ /* error comes in here */
                         print ("Tweet Matched.\n");
                         match = match + 1;
                 }

                 if ((tweet[0] = '.')){
                         printf("%d tweet(s) matched\n", match);
                         break;
                  }
          }
return 0;
}

(如果有任何拼写错误,那是因为我必须手动键入代码,因为它不允许我从编译器复制粘贴......)

基本上,我试图绕过警告“如果可能的话,‘target_tweet’的地址永远不会为 NULL。我 100% 无能为力。

最佳答案

这里有一个拼写错误

strcmp(tweet, target_tweet == 0)

这应该是

strcmp(tweet, target_tweet) == 0

关于c - 'target_tweet'的地址永远不会是NULL!?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27576311/

相关文章:

c++ - 在特定内存地址创建堆,用于动态内存分配

java - 我应该避免在我的 java 函数中返回 null 吗?

mysql - MySQL 中的 Left Join 返回空值,但它们不应该返回空值

C - 带有格式化字符串的 strcmp()

C - 条件语句 & strcmp & NULL 字符串

iphone - 2 字节数组/内联 c 数组的相等性

c - 为什么 Hackerrank 显示以下 C 代码的段错误?

c - 有没有办法在 strcmp 中使用 char?

c++ - 您如何在没有嵌套作业对象的情况下可靠地控制子流程的生命周期?

null - Kotlin设置为Null(如果不为Null)