CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
//This function is used to compare the string arguments.
//It compares strings lexicographically which means it compares both the strings character by character.
int strcmp(char* s1,const char* s2)
{
for(; *s1 == *s2; s1++, s2++)
{
if(*s1 == 0)
{
return 0; //If no match or null
}
else
{
return (int)(*s1-*s2); //ASCII
}
}
}
int main()
{
char string1[20]="ChandlerBing";
char string2[20]="MonicaBing";
cout<<"String1: "<<string1<<" & String2: "<<string2;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run