Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.05 KB

File metadata and controls

51 lines (39 loc) · 1.05 KB

SEEK_SET

  • cstdio[meta header]
  • macro[meta id-type]
#define SEEK_SET unspecified
  • unspecified[italic]

概要

ファイルの先頭位置を指定するための整数定数。

ファイルの先頭からのオフセットとして位置を指定する。

fseek()関数のorigin引数として指定する。値は処理系定義の整数定数式であり、SEEK_SETSEEK_CURSEEK_ENDは互いに異なる値をもつ。

#include <cstdio>

int main()
{
  std::FILE* fp = std::fopen("test.txt", "wb+");
  std::fputs("ABCDEF", fp);

  // ファイルの先頭から2バイトの位置へ移動する
  std::fseek(fp, 2, SEEK_SET);
  std::printf("%ld\n", std::ftell(fp));

  std::fclose(fp);
}
  • SEEK_SET[color ff0000]
  • std::fseek[link fseek.md]
  • std::ftell[link ftell.md]
  • std::fopen[link fopen.md]
  • std::fclose[link fclose.md]
  • std::fputs[link fputs.md]
  • std::printf[link printf.md]
  • std::FILE[link file.md]

出力

2

関連項目