programming-examples/c++/1_Overview/C++ Program to Compare Two Strings Using Pointers.cpp
2019-11-15 12:59:38 +01:00

32 lines
667 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<iostream>
#include<stdio.h>
using namespace std;
main() {
char str1[50],str2[50];
int str_cmp(char*,char*);
cout<<Enter first string:;
gets(str1);
cout<<Enter second string:;
gets(str2);
if(str_cmp(str1,str2))
cout<<nStrings are equal; else
cout<<nStrings are not equal;
return 0;
}
int str_cmp(char *s1,char *s2) {
while(*s1==*s2) {
if(*s1==||*s2==)
break;
s1++;
s2++;
}
if(*s1==&&*s2==)
return 1;
return 0;
}