Borland C++ reference

fgetc

raw OCR

Gets character from stream.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
int fgetc(FILE *stream);

Portability

DOSUNIXWindowsANSI CC++ only
■■■■

Remarks

fgetc returns the next character on the named input stream.

Return value

On success, fgetc returns the character read, after converting it to an int without sign extension. On end-of-file or error, it returns EOF.

See also

Example

#include <string.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   FILE *stream;
   char string[] - "This is a test", ch;

   /* open a file for update */
   stream = fopen ("DUMMY.FIL", "w+");
   /* write a string into the file */
   fwrite(string, strlen(string) , 1, stream);

   /* seek to the beginning of the file  */
   fseek(stream, 0, SEEK_SET);
   do {
      ch = fgetc (stream);  /* read a char  from the file */
      putch(ch);            /* display the character  */
   }
   while (ch != EOF);
   fclose(stream);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.