mercredi 1 décembre 2021

how input char array works while using in if condition [closed]

I tried following code but I didn't getting desire output

char a[50];

char b[50] = "abc";

std::cin << a ;

if(a == b){

std::cout << "Matched!!" << std::endl;

}else{

std::cout << "Not Matched!!" << std::endl;

}

I'm getting "Not Matched!!" while I put input as "abc". Why this happend?

Aucun commentaire:

Enregistrer un commentaire