To better understand run this program and read strcmp
#include <stdio.h>
#include <string.h>
int main()
{
char string1 [] = "Hello";
char string2 [] = "Hello";
// checking base address of string1 and string2, which will not be equal
if (string1 == string2) {
printf("Equal : string1 = %u and string2 = %u\n", string1, string2);
} else{
printf("Not Equal : string1 = %u and string2 = %u\n", string1, string2);
}
// strcmp checks the contents that are stored in string1 and string2
if(strcmp(string1, string2) == 0) {
printf("Equal\n");
}else {
printf("Not Equal\n");
}
return 0;
}