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

履歴 編集

function
<cstdio>

std::fscanf

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

概要

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

#include <cstdio>

int main() {
  int n;
  const char* path = "test.txt";
  std::FILE* fp = std::fopen(path, "r");
  std::fscanf(fp, "%d", &n);
  std::fclose(fp);
  std::printf("%d\n", n);
}

出力(test.txtは以下参照)

123

ファイル内容(test.txt)

123

処理系