if I have
char a[4];
char b[4];
is the following legal in c:
if (b == a)
These are NOT character strings just character arrays
Printable View
if I have
char a[4];
char b[4];
is the following legal in c:
if (b == a)
These are NOT character strings just character arrays
Legal - yes
Useful - no
Indeed, using the equality operator on two arrays is perfectly valid C, although it would only produce the desired result if those two arrays were actually the exact same array in memory. That happens because C compares addresses (because the name of an array is interpreted as the address of its first element), not contents. If you want to compare the contents, you can use memcmp().