Language = C. Please give an answer with explanation. 29. The file emp.bin conta
ID: 3707156 • Letter: L
Question
Language = C. Please give an answer with explanation.
29. The file emp.bin contains 60 integers. What will be the size of the file emp.bin after the execution of the following coded? int main () FILE *fid = NULL; int buf [5] {1, 2, 3, 4, 5); = fid fopen ("emp.bin","w+") if (fid== NULL) return (1); fwrite (buf, , sizeof (buf [1]), fid); fclose (fid); return (0) 30. The file emp.bin contains 60 integers. What will be the size of the file emp.bin after the execution of the following coded? int main ) FILE *fid int buf [5] NULL ; = {1, 2, 3, 4, 5); fid fopen ("emp.bin", "r+") if (fid== NULL) return (1); fseek (fid, 0, SEEK END); fwrite (buf, , sizeof (buf [1]), fid); fclose (fid); return (0)Explanation / Answer
29) Answer : 5
Explanation: File already contains 60 integer, we have opened the file using w+ mode . w+ mode deletes the content of the file. When we write buffer to it so total data and size will become 5
30) Answer : 65
Explanation: File already contains 60 integer, we have opened the file using r+ mode. r++ mode doesnt delete the content of file . So file data will be appended to next 60 integers and we write buffer to it so total data and size will become 65
Thanks, PLEASE UPVOTE if helpful
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.