K&R C Exercise 8-3: Write _flushbuf, fflush and fclose

Exercise 8-3. Design and write _flushbuf, fflush, and fclose. Exercise 8-2 built the read half of a miniature stdio; this one builds the write half. The design mirrors getc/_fillbuf: putc is a macro that drops characters into a buffer, and only when the buffer fills does it call the real function — _flushbuf — which …

K&R C Exercise 8-1: cat with read, write, open and close

Exercise 8-1. Rewrite the program cat of Chapter 7 using read, write, open and close instead of their standard library equivalents. Perform experiments to determine the relative speeds of the two versions. The Chapter 7 cat goes through the standard library — getchar and putchar — which quietly buffer I/O for you. This exercise drops …

C Program Examples Is Live on Product Hunt

Big day for this site: C Program Examples is live on Product Hunt today. If you’ve found the tutorials, quizzes, or K&R solutions here useful, dropping by the launch page to say hello (or leave honest feedback) would mean a lot — it’s a 24-hour window, and every comment helps other C learners discover the …

25 C Memory Management Interview Questions and Answers (with Code)

Memory management is where C interviews get serious. Pointers test syntax — memory questions test whether you can be trusted with a production codebase. This page collects 25 real C memory management interview questions with clear answers and tested, compilable code: stack vs heap, the malloc family, leaks, dangling pointers, double free, struct padding, and …