GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::ungetc - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. cstdio
  3. ungetc

最終更新日時: 2026年09月08日 16時16分41秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<cstdio>

std::ungetc

namespace std {
  int ungetc(int c, FILE *stream);
}

概要

符号なしの文字cを入力ストリームstreamに戻す。

この関数は、連続してこの関数が呼び出される場合、入力ストリームへのプッシュ・バックを保証できる連続した文字は 1 つのみである。

また、cはEOFであってはならない。

この関数が呼び出されたのち、fseekやfsetpos、rewind、fflushを呼び出すと、その関数の呼び出しによって戻された文字は失われる。

戻り値

成功したら挿入したcを、そうでなければEOFを返す。

例

#include <cstdio>

int main() {
  std::putchar(std::getchar());
  std::ungetc('A', stdin);
  std::putchar(std::getchar());
}

入力

a

出力

aA

処理系

  • Clang: ??
  • GCC: ??
  • Visual C++: ??
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.