(c) [3 marks] Mehdi is writing C code that, when opening a file fails, prints the cause according to errno: FILE *f = if

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

(c) [3 marks] Mehdi is writing C code that, when opening a file fails, prints the cause according to errno: FILE *f = if

Post by answerhappygod »

C 3 Marks Mehdi Is Writing C Code That When Opening A File Fails Prints The Cause According To Errno File F If 1
C 3 Marks Mehdi Is Writing C Code That When Opening A File Fails Prints The Cause According To Errno File F If 1 (117.04 KiB) Viewed 37 times
(c) [3 marks] Mehdi is writing C code that, when opening a file fails, prints the cause according to errno: FILE *f = if (f == fopen ("blabhlah", "w") ; NULL) { fprintf(stderr, "boom!\n"); fprintf(stderr, "fopen failed: %s\n", strerror(errno)); } else { } What mistake has Mehdi made? (Even though it may or may not actually break under all circumstances.) Also, suggest one way to rectify it. (No one was electrically shocked in the making of this question.)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply