second string and then adds the result to the result

for this program when it manipulations the second function i need help getting
it to add the second function when it is manitipated to add to the first function here is the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#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; 
}
Topic archived. No new replies allowed.