getchar - C stdio.h

C examples for stdio.h:getchar

Type

function

From


<cstdio>
<stdio.h>

Description

Returns the next character from the standard input (stdin).

It is equivalent to calling getc with stdin as argument.

Prototype

int getchar ( void );

Parameters

none

Return Value

On success, the character read is returned.

Example

The following code prints all characters read from keyboard.

Demo Code


#include <stdio.h>

int main ()//  w w w.  j a  v a 2s  .co  m
{
  int c;
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");

  do {

    c=getchar();

    putchar (c);

  } while (c != '.');

  return 0;
}

Related Tutorials