Skip to content
UPEEC

fopen and fclose

Open and close streams.

Beginner
Comments 0
FILE *f = fopen("log.csv", "a");
if (!f) { perror("log.csv"); return 1; }
fprintf(f, "%lu,%.3f\n", t, v);
fclose(f);

Modes: r, w (truncate), a (append), r+, w+, a+, plus b for binary.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.