Define two function in a class name matching. In the first function pass a single char array and match the repeated characters. The second function have two char array parameter and match that both are same strings or not.
#include<iostream>
#include<string.h>
using namespace std;
class name{
public:
void firstFunction(char arr[], char arr2[], int n, int x){
int size =n;
if(x>n){
size = x;
}
int i;
for(i=0; i<size; i++){
if(arr[i]==arr2[i]){
cout<<"Matching\n";
}
else{
cout<<"Not matching\n";
}
}
}
void secondFunction(char arr[], char arr2[], int n, int x){
int size =n;
if(x>n){
size = x;
}
int i;
bool found = true;
for(i=0; i<size; i++){
if(arr[i] !=arr2[i]){
found = false;
}
}
if(found==true){
cout<<"The strings are matching\n";
}
else{
cout<<"The string are not matching\n";
}
}
};
int main(){
name n;
n.secondFunction("java", "java",4,4);
}
Comments
Leave a comment