possible assignment in condition (C)

后端 未结 2 395
鱼传尺愫
鱼传尺愫 2021-01-21 19:40

I have to find is the number \"a\" a two-digit odd. Mistake comes on if

#include 
main ()
{
    int a,k;
    int count=0;
    printf (\"input numb         


        
2条回答
  •  孤独总比滥情好
    2021-01-21 20:10

    GCC is complaining about this:

    if (k = 1 && count = 2)
    

    The equality operator is a double equals sign: ==. What you've used, the single equals sign =, is the assignment operator.

    You are setting k to 1 and count to 2, and that if will always be executed.

    The message you're getting is designed to help people quickly catch exactly this problem.

提交回复
热议问题