Compairing Two String in C++ Program

#include <iostream>
using namespace std;
#include <cstring>
int main()
{
    char i[25]="Hello";
    char j[25]="World";
    char k[25]="Hello";
    cout<<"i is: "<<i<<endl;
    cout<<"j is: "<<j<<endl;
    strcat(i,j);
    cout<<"After Compairing:"<<endl;
    cout<<strcmp(i,j)<<endl;
    cout<<strcmp(i,k)<<endl;
    system("pause");
    return 0;
}


The output is given below:
i is: Hello
j is: World
After Compairing:
-1
1

0 comments:

Post a Comment