Hello,
Yes I have question I am trying to call a function that would allow me to use the string I entered in the cin.getline. Well basically here is the problem:
-Function 2: (Accept three arguments: an array and two characters, and return no value)
This function will accept an array containing the string and two characters. It will scan for the first character and when it finds the character, it will substitute the first character with the second character. Prompt for the character to be scanned and the character to be substituted in main() and pass those into the function.
I have already done function 1, I just need to do function 2 but here is the program hat I have written don there are some errors though becuase I was trying to get the first function to pass to the next function.
insert
Code:
#include <iostream>
using namespace std;
char Menu();
void insrt_ch(char[], char , char);
//int (char*[], char);
int main()
{
char Twinkle[80] = {' '};
char select = ' ';
char Sub_char = 'A';
char count = 'B';
char cont = 'Z';
cout <<"Please enter a string: ";
cin.getline(Twinkle, 80);
cout <<"\n";
cout << "Welcome to the string program ! \n";
cout << "=============================== \n";
cout << "A - Substitute Character \n";
cout << "B - Count Character \n";
cin >>select;
if(select != 'A')
{
cout << "Invalid selection! Please re-enter!";
cin >> select;
}
void insrt_ch(char String_1[80], char select, char Next)
{
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;
insrt_ch(char String_1[80], char select, char Next);
while(String_1[i] != '\0')
{
cout << String_1[i];
++i;
}
break;
default: cout << endl << endl;
break;
}
}
while(select != 'Z');
system("pause");
return 0;
}
If you have any other questions or concern please let me know and thank you