Assume your team is part of a research project. Your team wants to create a simple software that compares two strings, but they're undecided about whetheror not to use pointers. Your group now has the duty of creating or converting your initial code into a pointer-based compare two strings program and determining whether or not pointers are useful in this program.
Example like this:
#include <iostream>
using namespace std;
string convert(string s)
{
for (int i=0; i<s.length() ;i++)
{
s[i]=toupper (s[i]);
}
return s;
}
int main()
{
string string01,string02;
cout<<"String 1 : ";
cin>>string01;
cout<<"String 2 : ";
cin>>string02;
if(convert(string01)==convert(string02)) {
cout<<"Two strings is equal";
}
else{
cout<<"Two strings is not equal";
}
}
Comments
Leave a comment