Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c++ please Arguments The first command-line arguments should be options: f format Specify the format, to be given to strftime ( ). For example,
In c++ please
Arguments The first command-line arguments should be options: f format Specify the format, to be given to strftime ( ). For example, a format of "\%A \%B \%" would give output of Wednesday March 01 for a date of today. i Specify a format that will write the date in the ISO 8601 format of YYYY-MM-DD, exactly four digits (year), a hyphen, exactly two digits (month), another hyphen, and exactly two more digits (day of month). Today would produce 2023-03-01. v Announce, to standard output, each file as it is read. Display Processing filename for each file, and Processing standard input for standard input. % cat pearl 19411207 00000000001941.00000341 % cat limits 1.1 00010101 9999.365 99991231 % echo ToDay |./hw3 Mon Feb 202023 % echo YESterDaY | ./hw3 -f 'Day \%d of the month of \%B of the year \%Y' Day 19 of the month of February of the year 2023 Yes, that last example really is correct. Only read standard input if no filenames are given. Requirements - Error messages: - go to standard error - include the program name, no matter how it was compiled - include the entire input line, if not of one of the acceptable formats, or has an invalid value. - Produce an error message and stop the program if: - an option is bad - a file cannot be opened - an input line is not of one of the acceptable formats. - If more than one problem exists, you don't have to report them all. Produce one error message and stop. - Options: - An invalid -f format string (e.g., -f \%Q) has undefined results. - A format string with hour/minute/second specifiers (e.g., \%H, \%M, \%S, \%c) has undefined results. - You may assume that the f format string will result in no more than 64 characters. - It is an error to specify - f more than once, or to specify both f and i. - If neither f nor i is given, use the format shown in the examples, which is different than that of HW1. - The i and v options may be specified multiple times, with no additional effect. - Options must precede filenames. ./hw3 -i infile -v must attempt to process the file -v, which would probably fail. - Bundling of options must work: ./hw3 - vi data1 data13968339 is the same as ./hw3 -v -i data1 data13968339 ./hw3 -f'\%a/\%b' -v data is the same as./hw3 -f '\%/\%' - data ./hw3 -vf "date: \%c" is the same as. /hw3 -v -f "date: \%c" ./ hw3 -fv "\%c" is the same as ./ hw3 fv "\%" (which will treat v as a format, and \%c as a filename) / hw3 -v-f "\%c" data is invalid. - UPPERCASE/lowercase matters. - Spaces matter. - Blank lines matter. - Extra output matters. - You may not use any external programs via system( ), fork (), popen( ), execl(), execvp(), etc. - You may not use C-style l/0 facilities such as printf( ), scanf(), fopen(), and getchar (). - Instead, use C++ facilities such as cout, cerr, and ifstream. - You may not use dynamic memory via new, delete, malloc(),calloc(),realloc(), free (), strdup (), etc. - It's ok to implicitly use dynamic memory via containers such as string or vector. - You may not use the istream: : eof() method, even if called via other syntax such as cin. eof(). - No global variables. - Except for an optional single global string containing argv[0]. - For readability, don't use ASCll int constants (65) instead of char constants ( 'A' ) for printable characters. - We will compile your program like this: cmake . \&\& make - If that generates warnings, you will lose a point. - If that generates errors, you will lose all points. - There is no automated testing/pre-grading/re-grading. - Test your code yourself. It's your job. - Even if you only change it a little bit. - Even if all you do is add a comment. If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here. Hints - Use getopt. Seriously, use it. Don't do this yourself. You will have to actually read the manual page for getopt. This is a skill that you must acquire to be a good programmerStep 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