Question
Can someone fix this code please? #include #include #include #include #include #include using namespace std; bool emptyFile(ifstream& pFile) { return pFile.peek() == std::ifstream::traits_type::eof(); } void
Can someone fix this code please?
#include
bool emptyFile(ifstream& pFile) { return pFile.peek() == std::ifstream::traits_type::eof(); }
void displayCharactersWithOccurrences(map
for (auto p : m) { v.push_back(p); }
sort(v.begin(), v.end());
for (auto x : v) { cout
}
int main() {
map
cin >> fileName;
ifstream f; f.open(fileName);
if (f.fail()) cout
while (!f.eof()) { getline(f, temp); for (char s: temp) { if (isalnum(s)) { if (isalpha(s)) ocr[toupper(s)]++; else ocr[s]++; } else if (!isspace(s)) { ocr[s]++; non_alnum++; } } }
for (char i = '0'; i
for (char i = '0'; i
for (char c = 'A'; c
cout
displayCharactersWithOccurrences(ocr);
cout
}
return 0; }
Testing files
infile (it should print out file cannot be opened.)
file1 (this is an empty file)
file2
3456 1025 1234 45 4321 125 278 1025
file3
Prior to the launch of new technologies we hear of the benefits these latest developments will bring. As the latest innovations become integrated with, and form the infrastructure of, everyday living, we begin to experience some less positive aspects. Clearly, computer technology brings both benefits and disadvantages - the degree to which either has an impact on individuals and their ability to live a "good life"^ is the degree to which ethics is relevant to computing. A number of ethical issues have been discussed and debated over the last twenty years or so under the broad category of "computer ethics". This rather loose term has been criticised for placing ethics - a uniquely human characteristic - onto computers. Despite early predictions in Artificial Intelligence we are still far from being able to ascribe a moral viewpoint to mechanical devices. If, however, we talk about the ethics of computing we are talking about the use of computers - thus placing the moral perspective (and consequently the moral responsibility) firmly in the hands of computing professionals and the users.
file4
An International Standard Book Number (ISBN) is a code of 10 characters, referred to as ISBN-10, separated by dashes such as 0-7637-0798-8. An ISBN-10 consists of four parts: a group code, a publisher code, a code that uniquely identifies the book among those published by a particular publisher, and a check character. The check character is used to validate an ISBN. For the ISBN 0-7637-0798-8, the group code is 0, which identifies the book as one from an English-speaking country. The publisher code 7637 is for "Jones and Bartlett Publishers".
CS 280 Spring 2021 Recitation Assignment 4 February 15, 2021 Due Date: Wednesday, February 17, 2021, 23:59 Total Points: 0 Write a Ch program that creates a simple directory for the occurrences of printable characters read from an input file. The program should read from a file name specified in the command line as an argument. However, il no file name is provided, the program should print on a new line "No lile is kourd', and exit. If the file cannot be opened, peint on a new line "File cannot be opened, followed by the file name, and exit. The program should read from the file words until the end of file. If the input file is enpty, print out on a new line the message "File is empty." and then exit, word is defined as a contiguous number of non-whitespace characters separated by whitespace. The program should keep a record of the number of occurrences of each eller, decimal digit (0- 9), and any non-alphanumeric characters (eg,',7,'@", etc.) in a directory huilt using the
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started