

putc()                        STDIO                        putc()




Write character into stream

#include <stdio.h>
iinntt ppuuttcc(_c, _f_p) cchhaarr _c; FFIILLEE *_f_p;

putc is  a macro that writes  a character c into  the file stream
pointed to by fp.  It returns c upon success.

***** Example *****

The following example  demonstrates putc.  It opens an ASCII file
and prints  its contents on  the screen.  For  another example of
putc, see the entry for getc.


#include <stdio.h>
main()
{
        FILE *fp;
        int ch;
        int filename[20];



        printf("Enter file name: ");
        gets(filename);



        if ((fp = fopen(filename,"r")) != NULL) {
                while ((ch = fgetc(fp)) != EOF)
                        putc(ch, stdout);
        } else
                printf("Cannot open %s.\n", filename);
        fclose(fp);
}


***** See Also *****

fputc(), getc(), putchar(), STDIO

***** Diagnostics *****

putc returns EOF when a write error occurs.

***** Notes *****

Because putc is a macro, arguments with side effects may not work
as expected.






COHERENT Lexicon                                           Page 1


