I am learning c programming at school, and having a question about char*. I initialized char* str5 and char* str6, and their values are the exact same. what I want to confirm is that if I compare them in if statement, is it always comparing its addresses? If so, Why?
char* str5 = "hold";
printf("str5: %s\n", str5, str5);
char* str6 = "hold";
if (str5 == str6){
printf("str5 and str6 point to the same address\n");
}
else{
printf("str5 and str6 point to different addresses\n");
}
I appreciate any feedback, thank you so much!
Aucun commentaire:
Enregistrer un commentaire