Question: My code is not working for file 3 and file 4 can someone please fix it? #include #include #include #include using namespace std; //Function prototype
My code is not working for file 3 and file 4 can someone please fix it?
#include
int main (int argc, char *argv[]) { //Variables for counting int lic=0; int lc, wc, cc, dc; string fileName; //Arguments presentt or not check if (argc > fileName; } else{ fileName=argv[1]; } ifstream in; in.open(fileName); //File open or not check if (!in) { cout
}
/* Function: findLineCount ParamIn: lc,wc,cc,dc,in - reference variables ParamOut: None Description: Read line by line,count lines,words digit and characters */ void findLineCount (int &lc, int &wc, int &cc, int &dc, ifstream & in) { lc = 0, wc = 0, cc = 0, dc = 0; string line, word; while (getline (in, line)) { lc++; stringstream ss (line); while (getline (ss, word, ' ')) { wc++; } for (int i = 0; i
Input file 3
Input file 4
FILE 3 AND FILE 4 SHOULD GET THIS OUTPUT
![& in); int main (int argc, char *argv[]) { //Variables for counting](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f460ef681d8_63066f460eef025e.jpg)
Write a C++ program that reads from a file name specified in the command line as an argument, and ignores any extra command line arguments that are provided after the file name. However, if no file name is provided, the program should use the standard input instead of a file. If the file cannot be opened, print on a new line "File cannot be opened: ", followed the file name, and exit. The program should read from the file character by character until the end of file. If the input file is empty, print out the message "File is empty." on a new line and then exit. The program should count the number of lines, number of words, number of characters, number of digit characters (O' - 9'), and the number of alphabetic characters seen in the file. For example, with an input file of the following contents: 3456 Georgre 1234 smith 4321 staci 278 sandra 10.25 4.5 12.75 25.35 The displayed output is as shown below: LINES: 4 WORDS: 12 CHARS: 75 DIGITS: 29 LETTERS: 21 myfile4.txt An International Standard Book Number (ISBN) is a code of 10 characters, referred to as ISBN-10, separated by dashes such as 07637-07988. 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". RUNNING LINES: 4 > WORDS: 12 > CHARS: 75 > DIGITS: 29 > LETTERS: 23 RESULT: stdin [ 0 / 1] RUNNING myfile4 File is empty. 1c1,5 LINES: 5 > WORDS: 90 > CHARS: 553 > DIGITS: 31 > LETTERS: 402 RESULT: files [ 0 / 1] SUMMARY: RESULT: compiles [ 1 / 1] RESULT: cantopen [ 1 11 ] RESULT: empty [ 1 / 1 ] RESULT: stdin [0 / 1] myfile3.txt 3456 Georgre 10.25 0.95. 1234 smith 4.5 4321 staci 12.75 278 sandra 25.35 OOooooo
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
