#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; }
C++ Program to Compare Two Strings Using Pointers
Levels of difficulty: medium / perform operation:
- C++ Program to Compare Two Strings Without Using Pointers
- C++ Program to convert first letter of each word of a string to uppercase and other to lowercase
- C++ Program to Find Substring in String (Pattern Matching)
- C++ Program to Remove Spaces From String
- C++ Program to Compare Two Strings Using Pointers
- C++ program to swap two numbers using pointers
- C++ program to check the entered character is capital letter, small letter, digit or a special character