最終更新日時:
が更新

履歴 編集

function
<cwchar>

std::swscanf

namespace std {
  int swscanf(const wchar_t* s, const wchar_t* format, ...);
}

概要

書式を指定して、ワイド文字列領域から入力する。

戻り値

代入に成功した項目の数を返す。最初の変換が行われる前に入力が終端に達した場合はWEOFを返す。

#include <cwchar>
#include <iostream>

int main()
{
  int year = 0;
  int month = 0;
  int day = 0;
  int count = std::swscanf(L"2026-09-08", L"%d-%d-%d", &year, &month, &day);

  std::wcout << count << L": " << year << L'/' << month << L'/' << day << std::endl;
}

出力

3: 2026/9/8

バージョン

言語

  • C++98

関連項目