On this page
  1. fprintf
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

fprintf

Prev: printf | Up: stdio.h | Next: snprintf
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — fprintf
Tags: #public #prog #c #stdlib #stdio #tier/core


Include

#include <stdio.h>

Signature & Overview

int fprintf(FILE *restrict stream, const char *restrict fmt, ...);

Writes formatted output to a specific FILE * stream (such as stderr or an open file).

Notes & Pitfalls

Example

#include <assert.h>
#include <stdio.h>

int main(void) {
    FILE *f = tmpfile();
    assert(fprintf(f, "port=%d\n", 8080) > 0);
    fclose(f);
}

Linked from

Related notes