|
|
1.1 ! root 1: ! 2: ! 3: putc() STDIO putc() ! 4: ! 5: ! 6: ! 7: ! 8: Write character into stream ! 9: ! 10: #include <stdio.h> ! 11: iinntt ppuuttcc(_c, _f_p) cchhaarr _c; FFIILLEE *_f_p; ! 12: ! 13: putc is a macro that writes a character c into the file stream ! 14: pointed to by fp. It returns c upon success. ! 15: ! 16: ***** Example ***** ! 17: ! 18: The following example demonstrates putc. It opens an ASCII file ! 19: and prints its contents on the screen. For another example of ! 20: putc, see the entry for getc. ! 21: ! 22: ! 23: #include <stdio.h> ! 24: main() ! 25: { ! 26: FILE *fp; ! 27: int ch; ! 28: int filename[20]; ! 29: ! 30: ! 31: ! 32: printf("Enter file name: "); ! 33: gets(filename); ! 34: ! 35: ! 36: ! 37: if ((fp = fopen(filename,"r")) != NULL) { ! 38: while ((ch = fgetc(fp)) != EOF) ! 39: putc(ch, stdout); ! 40: } else ! 41: printf("Cannot open %s.\n", filename); ! 42: fclose(fp); ! 43: } ! 44: ! 45: ! 46: ***** See Also ***** ! 47: ! 48: fputc(), getc(), putchar(), STDIO ! 49: ! 50: ***** Diagnostics ***** ! 51: ! 52: putc returns EOF when a write error occurs. ! 53: ! 54: ***** Notes ***** ! 55: ! 56: Because putc is a macro, arguments with side effects may not work ! 57: as expected. ! 58: ! 59: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.