
Compare Strings in C
Simple code which compares strings in C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> int main() { char a[100], b[100]; printf("Enter string one: "); scanf ("%s", &a); printf("Enter string two: "); scanf ("%s", &b); if( strcmp(a,b) == 0 ) printf("**They are equal**\n"); else printf("**They are NOT equal**\n"); system("pause"); return 0; } |
Read More