Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)


    int fgetc ( FILE * stream );

Returns next character from (input) stream stream, or EOF on end-of-file or error.

C Sourcecode Example

 * fgetc example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
int main( void )
  FILE *stream;
  char c;
  if((stream=fopen("test.txt","r"))==NULL) {
    printf("Cannot open file.\n");
    return 1;
  while((c = fgetc(stream) ) != EOF) {
    printf("%c", c);
  return 0;


test.txt contents

Line 1
Line 3
#Line 4 
Line 5

fgetc output

if test.txt exists

  output: ./fgetc 
  Line 1
  Line 3
  #Line 4 
  Line 5

if test.txt not exists

  output: ./fgetc 
  Cannot open file.
c/stdio.h/fgetc.txt · Last modified: 2014/12/04 13:27 by Daniel Gohlke

The new Question & Answer System is online and waiting for your Questions about Programming problems Impressum