+ 1

char b[]="abc"; char a[]="abc"; cout<<(a==b);

why this are not equal pls help

16th Jul 2020, 7:14 PM
Deepak Dhan
Deepak Dhan - avatar
3 ответов
+ 1
I think it's because characters only occupy one byte each while string characters occupy (I think) 2 bytes each.
16th Jul 2020, 7:21 PM
Hilary
Hilary - avatar
0
codemonkey yes, I know. The question by Deepak Dhan was edited and he should have put an edit comment to avoid this confusion. He originally asked to compare a char array and a string.
16th Jul 2020, 9:11 PM
benjamin
0
What do you expect ? a refers to the address of first character of the char array and same for the other one . two addresses can not be same .
18th Jul 2020, 4:40 AM
Hima
Hima - avatar