Page 1 of 1

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

Posted: Fri Jul 08, 2022 7:27 am
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 38 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.)