getc, getwc

From RAD Studio
Jump to: navigation, search

Go Up to stdio.h Index


Header File

stdio.h

Category

Input/output Routines

Prototype

int getc(FILE *stream);

wint_t getwc(FILE *stream);

Description

Gets character from stream.

getc returns the next character on the given input stream and increments the stream's file pointer to point to the next character.

Note: For Win32 GUI applications, stdin must be redirected.

Return Value

On success, getc returns the character read, after converting it to an int without sign extension.

On end-of-file or error, it returns EOF.

Example

#include <stdio.h>
int main(void)
{
   char ch;
   printf("Input a character:");
/* read a character from the
standard input stream */
   ch = getc(stdin);
   printf("The character input was: '%c'\n", ch);
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

getc

+

+

+

+

getwc

+

+

+