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

履歴 編集

function
<cstdio>

std::getchar

namespace std {
  int getchar();
}

概要

標準入力から1文字入力する。

getcとは違い、関数として定義することが定められているため、引数は一度しか評価されないことが保証されている。

また、getc(stdin)と等価である。

戻り値

読み取る文字があればその文字を、なければEOFを返す。

#include <cstdio>

int main() {
  int c;
  while ((c = std::getchar()) != EOF) {
    std::putchar(c);
  }
}

入力

abc

出力

abc

処理系