Vasilena

PracticeDayFiveExercise2

Jul 9th, 2021 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. int Compare(const char* str1,const char* str2)
  2. {
  3.    while(*str1)
  4.    {
  5.        if(*str1 != *str2)
  6.        {
  7.             break;
  8.        }
  9.        str1++;
  10.        str2++;
  11.    }
  12.    return *str1 - *str2;
  13. }
  14.  
  15. int main()
  16. {
  17.   char str1[100];
  18.   char str2[100];
  19.   printf("Enter first string: ");
  20.   gets(str1);
  21.   printf("Enter second string: ");
  22.   gets(str2);
  23.   int result = Compare(str1, str2);
  24.   (result == 0)?printf("This strings are the same"):printf("This strings aren`t the same");
  25.   return 0;
  26. }
  27.  
Add Comment
Please, Sign In to add comment