putchar


putchar

Writes a character to standard output

 #include <stdio.h> int putchar ( int c  ); 

The macro putchar( ) is similar to putc( ), but rather than writing a character to a specified file, it writes to stdout, and hence has no FILE pointer argument.

Example

The following example code reads the beginning of a file repetitively, and reports its progress on stdout.

 long count; const long CYCLES = 5000; FILE *fp = fopen( "infile.txt", "r" ); char readback[1024]; for (count = 0; count <= CYCLES; ++count) {  /* Start output with '\r' to re-use same screen line. */   printf( "\rPerformed %li file reads. ", count );   rewind( fp );   fgets( readback, 1024, fp ); /* Scroll a new screen line every hundred cycles. */   if (count % 100 != 0) continue;     putchar( '\n' ); } puts( "Done." ); 

See Also

putc( ), getc( ), getchar( ), fgetc( ), fputc( ); the C99 functions to read and write wide characters, putwc( ), fputwc( ), and putwchar( ); getwc( ), fgetwc( ), and getwchar( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net