COMPARING TWO STRINGS

Description:

Write a program to input two strings from user and find whether these strings are equal or unequal without using string functions. Test Case 1 Input (stdin) elab universitylearningcentre Expected Output THE GIVEN TWO STRINGS ARE NOT SAME Test Case 2 Input (stdin) elabtool elabtool Expected Output THE GIVEN TWO STRINGS ARE SAME

Program :

#include <iostream>

#include<string.h>

using namespace std;

int main()

{

char str1[40],str2[40];

  int diff;

  cin>>str1;

  cin>>str2;

  diff=strcmp(str1,str2);

  if(diff==0)

    cout<<"THE GIVEN TWO STRINGS ARE SAME";

  else

    cout<<"THE GIVEN TWO STRINGS ARE NOT SAME";

return 0;

}