here is my code that works but for this program when it manipulations the second function meaning when it turns for example 23 to 32 i need help getting
it to add to the first function when it is manitipated here is the code.
Code:
#include<iostream.h>
#include<string>
#include<stdio.h>
//Function Prototype declaration
void searchChar(string);
void reversal(string&);
void caps(string&);
void printstr(string,string);
int main()
{
string str1,str2;
int choice;
cout<<"Please Enter String 1 : ";
cin>>str1;
cout<<"Please Enter String 2 : ";
cin>>str2;
cout<<"String 1 : "<<str1<<endl;
cout<<"String 2 : "<<str2<<endl;
do
{
cout<<"Options available for String 2 Manipulation : "<<endl;
cout<<"1. Search a character in String ?"<<endl;
cout<<"2. Reverse the String ?"<<endl;
cout<<"3. Change the case of String ?"<<endl;
cout<<"4. Reverse and Change Case of String ?"<<endl;
cout<<"5. EXIT ?"<<endl;
cout<<"Please Enter your choice : ";
cin>>choice;
switch(choice)
{
case 1 :
searchChar(str2);
printstr(str1,str2);
break;
case 2 :
reversal(str2);
printstr(str1,str2);
break;
case 3:
caps(str2);
printstr(str1,str2);
break;
case 4 :
reversal(str2);
caps(str2);
printstr(str1,str2);
break;
case 5 :
break;
default :
cout<<"Wrong Menu Choice!!"<<endl;
}
}while(choice != 5);
getchar();
return 0;
}
void searchChar(string st)
{
char ch;
int check = 0;
cout<<"Enter a character to search :";
cin>>ch;
for(int i=0;i<st.size();i++)
{
if(ch==st[i])
{
cout<<"Character \'"<<ch<<"\' is present in String \""<<st<<"\" at position : "<<(i+1)<<endl;
check++;
}
}
if(check == 0)
{
cout<<"Character not present in String 2. "<<endl;
}
}
void reversal(string& st)
{
char temp;
for(int i=0;i<st.size()/2;i++)
{
temp = st[i];
st[i] = st[(st.size() - i-1)];
st[(st.size() - i-1)] = temp;
}
}
void caps(string& st)
{
for(int i=0;i<st.size();i++)
{
if(st[i]>=97 && st[i]<=122)
st[i] = st[i] - 32;
}
}
void printstr(string st1,string st2)
{
cout<<endl<<"String : "<<st1<<" "<<st2<<endl<<endl;
}