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
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
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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().
Devoted my life to programming...