#include <iostream>
#include <string>
using namespace std;
int ProcessLine(char line[],char c);
int main()
{
char line[200], c;
int Count;
cout<<"Enter some text: ";
cin.get(line, 200);
cout<<"Enter a character: ";
cin>>c;
Count = ProcessLine(line, c);
cout<<endl;
cout<<"Count of "<<c<<" =
"<<Count<<endl;
cout<<"Modified line = "<<line<<endl;
return 0;
}
int ProcessLine(char line[], char c) {
int count=0;
for(int i = 0; i < sizeof(line)/sizeof(line[0]); i++) {
if(line[i]==c){
line[i]='*';
count++;
}
}
return count;
}
c++ Implement the following function: 1) Name: ProcessLine a. Parameters: Int 10 character array line, charc...
Here is the skeleton of the password checking program. We have the character counting function (you will need to finish it), and a function to check if the password is good. Change the password algorithm so that (three of the four) two uppercase, two lowercase, two digits, or one other is present. Also change the required length of the password to 10. Bonus points for making the program loop until a good password is entered. You will need to read...
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...
I'm getting a segmentation fault for this function, this is for a c++ program. Is there anything that you see that is obviously wrong? Am i using cin.get wrong? Please help if you can. number is my variable, and NUMBER is the const int limit void questions::addQuestion() { int i = 0; cout << "Enter the question number: " << endl; //after this line is where it seg faults cin.get(number,NUMBER, '\n'); cin.ignore(100, '\n'); cout <<...
Flatten Text: Write a function to implement simple string flatten operation with the help of number of occurrence of characters. For example, the string xxyzzzzzxxx results in x2ylz5x3. In case the "flattened" string doesn’t result in becoming shorter than what we started with, then the function simply returns the starting string. The string should use only uppercase and lowercase letters (a through z). #include <iostream> using namespace std; string flattenText(string str) { string flattenedText = ""; return flattenedText;...
Write a C++ program that contains 2 functions. LastLargestIndex, that takes as paraneters an int array and // its size and returns the index of the first occurrence of the largest element II in the array. Also, write a function to display the array #include ·peh.h" #include <iostream> using namespace std const int ARRAY_SIZE = 15; int main int list[ARRAY SIZE56, 34, 67, 54, 23, 87, 66, 92. 15, 32, 5, 54, 88, 92, 30 cout < List elements: "...
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...
// This program performs a linear search on a character array // Place Your Name Here #include <iostream> using namespace std; int searchList(char[], int, char); // function prototype const int SIZE = 8; int main() { char word[SIZE] = "Harpoon"; int found; char ch; cout << "Enter a letter to search for:" << endl; cin >> ch; found = searchList(word, SIZE, ch); if (found == -1) cout << "The letter " << ch << " was not found in the...
Implement and test a function that uses dynamic array to store students’ grades and calcuate the average grade. // This program demonstrates the use of dynamic array // it #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size = 2; grades = new float[size]; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total;...
(Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the date of birth. **fall.sort(compare_DOB); //Here lies your error** #include <fstream> #include <iostream> #include <string> #include <list> #include <cctype> using namespace std; const char THIS_TERM[] = "fall.txt"; const string HEADER = "\nWhat do you want to do ?\n\n" "\t. Add a new friend name and DOB ? \n" "\t. Edit/Erase a friend record ? \n" "\t. Sort a Friend's record ? \n"...
This is for a C++ program: I'm almost done with this program, I just need to implement a bool function that will ask the user if they want to repeat the read_course function. I can't seem to get it right, the instructions suggest a do.. while loop in the main function. here is my code #include <iostream> #include <cstring> #include <cctype> using namespace std; const int SIZE = 100; void read_name(char first[], char last[]); void read_course(int & crn, char des[],...