Advertisement
Guest User

839 Final Part 1

a guest
Dec 18th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. bool StringCompare(char[], char[]);
  5.  
  6. int main()
  7. {
  8.     char str1[80], str2[80];
  9.     bool result;
  10.  
  11.     cout << "Input first string: ";
  12.     cin >> str1;
  13.     cout << "Input second string: ";
  14.     cin >> str2;
  15.  
  16.     result = StringCompare(str1, str2);
  17.  
  18.     if(result == true)
  19.         cout << "Strings are equal\n";
  20.     else
  21.         cout << "Strings are not equal\n";
  22.  
  23.     return 0;
  24. }
  25.  
  26. bool StringCompare(char str1[], char str2[])
  27. {
  28.     bool result = true;
  29.  
  30.     for(int index = 0; index < 80 && result; index++) {
  31.         if(str1[index] != str2[index])
  32.             result = false;
  33.     }
  34.  
  35.     return result;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement