User Tools

Site Tools


c:stdio.h:getc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:getc [2013/01/22 22:02] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +
 +===== getc =====
 +<code c>
 +    int getc(FILE *stream);
 +</code>
 +
 +Returns next character from (input) stream stream, or EOF on end-of-file or error.
 +
 +===== C Sourcecode Example =====
 +<code c>
 +/* 
 + * getc example code
 + * http://code-reference.com/c/stdio.h/getc
 + */
 +
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +
 +int main( void )
 +{
 +    FILE *stream;
 +    int c;
 +
 +    if((stream=fopen("test.txt","r"))==NULL) {
 +        printf("Cannot open file.\n");
 +        return 1;
 +    }
 +      
 +   while((c = getc(stream) ) != EOF) {
 +        printf("%c", c);
 +     }
 +     
 +   fclose(stream);
 +   return 0;
 +}
 +</code>
 +
 +content of test.txt
 +<code c>
 +Test example file for code-reference.com getc source code
 +</code>
 +
 +==== output ====
 +    ./getc 
 +    Test example file for code-reference.com getc source code
 +
 +    
  
advertising
c/stdio.h/getc.txt · Last modified: 2013/01/22 22:02 (external edit)

Impressum Datenschutz