I think there is something wrong with my program I got this fom my TA and I think he kind of messed up somewhere I just don't know what to change:
[code=cpp]
#include <iostream>
using namespace std;
int String(char[]);
char Menu();
void Second(char, char, char[],int);
int main()
{
char Twinkle[80] = {' '};
char select = ' ';
char Sub_char = 'A';
char count = 'B';
char cont = 'Z';
cout <<"Please enter a string: ";
cin.getline(Twi nkle, 80);
cout <<"\n";
do
{
select = Menu();
if(select != 'A')
{
cout << "Invalid selection ! Please re-enter !\n";
cin >> select;
}
char String_1[80] = {' '};
char character = ' ';
char sub = ' ';
int i = 0;
switch(select)
{
case 'A':
case 'a':
{
cout << "Please enter the character to be scanned: ";
cin >> character;
cout << "Please enter the character to be substituted: ";
cin >> sub;
Second(characte r, sub, String_1, 80);
while(String_1[i] != '\0')
{
cout << String_1[i];
++i;
}
}
}
while(select != 'Z');
system("pause") ;
return 0;
}
}
char Menu()
{
cout << "Welcome to the string program ! \n";
cout << "============== =============== == \n";
cout << "A - Substitute Character \n";
cout << "B - Count Character \n";
cin >>select;
return select;
}
void Second(char Ch, char Su, char Str_2[],int num_1)
{
int i = 0;
cout << Ch;
cout << Su;
cout << "The updated String is: ";
while(Str_2[i] != '\0')
{
if(Str_2[i] == Ch)
{
Str_2[i] == Su;
}
i++;
}
}[/code]
[code=cpp]
#include <iostream>
using namespace std;
int String(char[]);
char Menu();
void Second(char, char, char[],int);
int main()
{
char Twinkle[80] = {' '};
char select = ' ';
char Sub_char = 'A';
char count = 'B';
char cont = 'Z';
cout <<"Please enter a string: ";
cin.getline(Twi nkle, 80);
cout <<"\n";
do
{
select = Menu();
if(select != 'A')
{
cout << "Invalid selection ! Please re-enter !\n";
cin >> select;
}
char String_1[80] = {' '};
char character = ' ';
char sub = ' ';
int i = 0;
switch(select)
{
case 'A':
case 'a':
{
cout << "Please enter the character to be scanned: ";
cin >> character;
cout << "Please enter the character to be substituted: ";
cin >> sub;
Second(characte r, sub, String_1, 80);
while(String_1[i] != '\0')
{
cout << String_1[i];
++i;
}
}
}
while(select != 'Z');
system("pause") ;
return 0;
}
}
char Menu()
{
cout << "Welcome to the string program ! \n";
cout << "============== =============== == \n";
cout << "A - Substitute Character \n";
cout << "B - Count Character \n";
cin >>select;
return select;
}
void Second(char Ch, char Su, char Str_2[],int num_1)
{
int i = 0;
cout << Ch;
cout << Su;
cout << "The updated String is: ";
while(Str_2[i] != '\0')
{
if(Str_2[i] == Ch)
{
Str_2[i] == Su;
}
i++;
}
}[/code]
Comment