
I need this in Visual Studio C++
#include <fstream>
#include <string>
#include <iostream>
#include <cwctype>
#include <cctype>
using namespace std;
string trim(string &str) {
str.erase(0, str.find_first_not_of(' ')); //prefixing spaces
str.erase(str.find_last_not_of(' ')+1); //surfixing spaces
return str;
}
bool is_vowel(char c) {
c = tolower(c);
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c ==
'u';
}
bool is_consonant(char c) {
return !is_vowel(c) && isalpha(c);
}
void writeStatistics(string content) {
content = trim(content);
int vowels = 0, consonants = 0;
int words = 0;
bool lastSpace = false;
if(content.length() != 0) {
words = 1;
lastSpace = true;
for(int i=0; i<content.length(); i++) {
char c = content.at(i);
if(iswspace(c)) {
if(!lastSpace) {
words++;
}
lastSpace = true;
} else if(is_vowel(c)) {
vowels++;
lastSpace = false;
} else if(is_consonant(c)) {
consonants++;
lastSpace = false;
}
}
}
ofstream myfile;
myfile.open ("output.txt");
myfile << "Vowels: "<< vowels << "\n";
myfile << "Consonants: "<< consonants <<
"\n";
myfile << "Words: "<< words << "\n";
myfile.close();
}
int main(int argc, char** argv) {
ifstream ifs("input.txt");
// populate file data in content variable
string content( (istreambuf_iterator<char>(ifs) ),
(istreambuf_iterator<char>()));
writeStatistics(content);
return 0;
}
========================================
Please save your data in a file input.txt and the statistics will be written to output.txt.

I need this in Visual Studio C++ Write a function that count the number of vowels,...
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...
Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...
(Count vowels and consonants, file input, nested-loops, switch statement) Assume that letters A, E, I, O and U are the vowels. Write a program that reads strings from a text file, one line at a time, using a while-loop. You do the following operations within each loop: Read one line from the input file and store it in a string; Count the number of vowels and consonants (using either while-loop or for-loop) in the file string. The while-loop...
(Count vowels and consonants) Assume letters A, E, I, O, and U as the vowels. Write a program that prompts the user to enter a string and displays the number of vowels and consonants in the string. using python
c++ microsoft visual studio Write a function that given a string it will return the number of vowels in the string. Function prototype is given by: int getNumVowels(string s1);
Use C++ and Visual Studio
Word Finder Version Your version of word finder should allow players to find as many words as they can from the list of letters. Name the cpp file called wordFinder LastNameFirstName.cpp. Words must contain at least 3 letters but no more than 6 letters The program must first read the words from a file but only can read in at most 5 words from a text file. The program should skip words that contains less...
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...
#include <iostream> #include <cstring> #include <string> #include <istream> using namespace std; //Function prototypes int numVowels(char *str); int numConsonants(char *str); int main() { char string[100]; char inputChoice, choice[2]; int vowelTotal, consonantTotal; //Input a string cout << "Enter a string: " << endl; cin.getline(string, 100); do { //Displays the Menu cout << " (A) Count the number of vowels in the string"<<endl; cout << " (B) Count...
I need help building a program on microsoft visual studio using c++ language. implement a program called "charword_freq.cpp" to determine the number of words and the number of occurrences of each letter in a block of text stored in a data file called “mytext.dat”. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of a line. You can assume that the input...
I need only one C++ function . It's C++ don't
write any other language.
Hello I need unzip function here is my zip function
below. So I need the opposite function unzip.
Instructions:
The next tools you will build come in a pair, because
one (zip) is a file compression tool, and
the other (unzip) is a file decompression
tool.
The type of compression used here is a simple form of
compression called run-length encoding (RLE). RLE is quite simple:
when...