vendredi 23 décembre 2016

Why not print 1 about if?

#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
    int a=1;
    if (a=0){
        printf("%d",0);
    }
    if (a!=0){
        printf("%d",1);
    }else{
        printf("%d",2);
    }
    return 0;
}

The a!=0 is right. Why not print 1 it print 2 now? I don't know why,how can i do ?

Aucun commentaire:

Enregistrer un commentaire