Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ putchar(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                              putchar(3C)



        _________________________________________________________________
        putchar                                                     macro
        Write a character to the standard output.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        char nextchar;
        putchar(nextchar);


          where   nextchar is the character to write out to the
                  standard output.



        Description

        The putchar macro writes a character to the standard output file.
        You cannot pass putchar as a parameter to a function or take its
        address, since it is a macro and not a function.  Use fputc
        instead.

        See the "I/O Functions and Macros" section of Chapter 1 for
        buffering information on the putchar macro.


        Returns

        The putchar macro returns the character it writes; it returns -1
        if an error occurs.


        Related Functions

        See also the fputc, getchar, putc, and puts functions.


        Example

        /* Program test for the putchar() macro on strings */

        #include <stdio.h>

        FILE  *fp, *fopen();
        int    c, i = 0;

        main(argc, argv)
        int    argc;



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                              putchar(3C)



        char  *argv[];
        {
            fp = fopen(argv[1], "r");
            while ((c = getc(fp)) != EOF) {
                putchar(c);
                i++;
            }
            printf("Bytes copied from %s to standard output = %d",
            argv[1], i);
        }

        A call to the program test with the filename to_term, which
        contains

        Please write this file to the terminal, if the terminal is the
        standard output file.

        generates the following output:

        Please write this file to the terminal, if the terminal
        is the standard output file.
        Bytes copied from to_term to standard output = 85
































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026