Use strcmp function to check whether strings are equal
/* Example: Check if strings are equals in C language */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <stdbool.h> #include <errno.h> #include <unistd.h> int main () { char str1[] = "hello!"; char str2[] = "hello!"; char str3[] = "halle"; if (strcmp(str1, str2) == 0) printf("str1 = str2\n"); if (strcmp(str1, str3) != 0) printf("str1 != str3\n"); // Using == does not tell if strings are equal: if (str1 == str2) printf("str1 = str2\n"); return 0; }