Can someone help me . This program needs to run in visual studio and written in c++. I want to call to the function string eraseChar in the main function to use the variables str and ch. I cannot use global variables.
#include<iostream>
#include <string>
using namespace std;
string eraseChar(char ch = 'e', string str = "the bike fell in the
water");
int main()
{
int pos;
pos = str.find(ch);
while (pos != string::npos)
{
str.erase(pos, 1);
pos = str.find(ch);
}
cout << str << endl;
system("pause");
return 0;
}
#include<iostream>
#include <string>
using namespace std;
string eraseChar(char ch, string str){
int pos;
pos = str.find(ch);
while (pos != string::npos)
{
str.erase(pos, 1);
pos = str.find(ch);
}
return str;
}
int main()
{
string str = eraseChar('e',"the bike fell in the water");
cout << str << endl;
system("pause");
return 0;
}


Can someone help me . This program needs to run in visual studio and written in...
Explain each line of the following code (Briefly) and give an overall reflection on using these particular functions. #include<iostream> #include<string> using namespace std; //declare a struct with field mentioned struct Unit { string unit_code; int unit_credict_hrs; int unit_semister_study; string prerequisites; string post_requisites; string number_post_requisites; }; int main() { Unit unit1; string str; cout << "Enter a tring: "; getline(cin, str); size_t index = 0; string tok,t, del=","; ...
My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all the upper, lower case and digits in a .txt file. The requirement is to use classes to implement it. -----------------------------------------------------------------HEADER FILE - Text.h--------------------------------------------------------------------------------------------- /* Header file contains only the class declarations and method prototypes. Comple class definitions will be in the class file.*/ #ifndef TEXT_H #define...
When I try to run the program it gives me an erron saying Expected expresion on this line, else if(phrase.find(sub_String)!=std::string::npos). #include #include #include using namespace std; int main( ) { // Defining variables. //Initilizing variables. int magicNum; int magicNum1; int position; int phraseLenght; string vowels = "aeiou"; string phrase; string sub; // The phrase and the sub phrase cout << "Enter a phrase:" << endl; std::getline (std::cin,phrase); cout << "Enter a 3-character sub:"...
The code will not run and I get the following errors in Visual Studio. Please fix the errors. error C2079: 'inputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' cpp(32): error C2228: left of '.open' must have class/struct/union (32): note: type is 'int' ): error C2065: 'cout': undeclared identifier error C2065: 'cout': undeclared identifier error C2079: 'girlInputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' error C2440: 'initializing': cannot convert from 'const char [68]' to 'int' note: There is no context in which this conversion is possible error...
I need help to fix this program it is written in c++ and needs to run in visual studio. Program uses character strings from a file containing on the first line and answer key and every other line after is the students ID number followed by a space then their test answers.Program currently reads only test answer key and student ID and their answers of second line. Sample data can be found below. TFTTFTFFFTTTFFTTFFFT HUB00123 TFTFFFTFTFTFTTTFTTTT SMU12456 FFTFTTFFTTTTTTFFTTFT #include #include #include...
Problem with C++ program. Visual Studio say when I try to debug "Run-Time Check Failure #2 - Stack around the variable 'string4b' was corrupted. I need some help because if the arrays for string4a and string4b have different sizes. Also if I put different sizes in string3a and string4b it will say that those arrays for 3a and 3b are corrupted. But for the assigment I need to put arrays of different sizes so that they can do their work...
when i run it is still be "false" i don't know why. could you
help me fix it and tell me which part is wrong??? specific answer
is better thanks!!!
Problem 6: (4 pts): Write a function that takes as an input parameter a string. It should return a Boolean value indicating whether the string is a palindrome or not. INPUT: “mom"->true “palindrome”->false “amanaplanpanama"->true 3 #include <iostream> #include <string.h> I using namespace std; string function(string str); int main() { function("palindrome");...
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...
This is a C++ Program I created in Visual Studio for class. The problem I am having is I get an error msg that says, "no matching token found for line 8." What am I missing? I see an opening bracket and a closing bracket. But, the program will not build because it says more or less the bracket is missing. FYI....Line 8, is the bracket directly under int main (). Can someone help me understand where I am going...
Can someone help run this and fix a small error I have when I run this. I get a constant variable error on line 62. I have a constant variable though and I'm sure what to change. I use Visual Basic 2017 as well for any of those wondering. Please help and thanks in advance #include <ctime> #include <iostream> #include <random> #include <string> using namespace std; int main() { const int paper = 0, rock = 1, scissors = 2;...