A String function,strcmp() are used here to compute with strings.
#include <stdio.h> #include <string.h> int main() { char str1[20] = "aroliant"; char str2[20] = "codecry"; if (strcmp(str1, str2) ==0) { printf("string 1 and string 2 are equal"); }else { printf("string 1 and 2 are different"); } return 0; }
string 1 and 2 are different
strcmp() compares both the string and return true(1) if both are same and false(0) if both are different.Here we have printed the statements directly.
Comments :