Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. int sameLocation (char str1[], char str2[]);
  2.  
  3. int sameLocation (char str1[], char str2[]) {
  4.  
  5.     int i, count = 0;
  6.    
  7.     for (i = 0; i < SIZE && str1 != NULL && str2 != NULL; i++) {
  8.             if (str1[i] == str2[i]) {
  9.                 count++;
  10.             }
  11.         }
  12.     return count;
  13. }
  14.  
  15.  
  16. int main() {
  17.  
  18.     char str1[SIZE], str2[SIZE];
  19.  
  20.     cout << "first string: ";
  21.     cin.getline(str1, SIZE);
  22.     cout << "second string: ";
  23.     cin.getline(str2, SIZE);
  24.     cout << endl;
  25.  
  26.  
  27.     cout << sameLocation (str1, str2) << endl;
  28.  
  29.  
  30.  
  31.     system("pause");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement