最終更新日時(UTC):
が更新

履歴 編集

function
<cstdio>

std::fprintf

namespace std {
  int fprintf( FILE* stream, const char* format, ... );
}

概要

指定されたファイルストリームに、指定された書式文字列を使用してデータを出力する。

#include <cstdio>

int main() {
  int n = 123;
  std::fprintf(stdout, "Hello, World!\n%d\n", n);
  const char* path = "test.txt";
  std::FILE* fp = std::fopen(path, "w");
  std::fprintf(fp, "Hello, World!\n%d\n", n);
  std::fclose(fp);
}

出力

Hello, World!
123

ファイル出力(test.txt)

Hello, World!
123

処理系