Q
In C, given char a[] = "hi", b[] = "hi";, what does a == b evaluate to?
-
A
Undefined behavior
-
B
Compilation error
-
C
False (0), because the comparison is between the two array addresses
-
D
True (1)
Correct Answer:
C. False (0), because the comparison is between the two array addresses
Explanation:
The arrays decay to pointers, so == compares their addresses. Use strcmp(a, b) == 0 to compare contents.