Question
I uploaded the sample please do it asap Use the program 7-6ErrorHandlingStderrExit.c on Canvas in Course Documents, Programs and Data File. When executing on the
I uploaded the sample please do it asap
Use the program 7-6ErrorHandlingStderrExit.c on Canvas in Course Documents, Programs and Data File. When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program.
The new code should within only this case situation
if (argc == 1){ /* no args; copy standard input */
Replace line #20 filecopy(stdin, stdout); with new code.
Open and read a text file 7NoInputFileResponse.txt that contains a response message There were no arguments on the command line to be read for file open. If file is empty, then use alternate message "22F Missing file 7-0NoInputFileResponse.txt" advance line.
Make the program output to the text log file a new line starting with formatted abbreviation for Weekday
Append that message to a file 7Error_Log_File.txt advance newline.
Remember to be using fprintf, using stderr, using return, using exit statements. Test for existence of 7NoInputFileResponse.txt file when not null print 7Error_Log_File.txt does exist however if null use, otherwise display such message using fprintf stderr and exit.
Upload your .c file your input message file and your text log file.
7-6ErrorHandlingStderrExit.c
#include
7-8MiscFunctionsTime
int main(void) { time_t t; time_t current_time; char* c_time_string; char buffer[SIZE]; time_t curtime; struct tm *loctime; /* Obtain current time. */ current_time = time(NULL); if (current_time == ((time_t)-1)) { (void) fprintf(stderr, "Failure to obtain the current time. "); exit(EXIT_FAILURE); } /* Convert to local time format. */ c_time_string = ctime(¤t_time); if (c_time_string == NULL) { (void) fprintf(stderr, "Failure to convert the current time. "); exit(EXIT_FAILURE); } /* Print to stdout. ctime() has already added a terminating newline character. */ (void) printf("Goodbye! "); printf("Current time is %s", c_time_string); exit(EXIT_SUCCESS); }
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