Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ putw(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 putw(3C)



        _________________________________________________________________
        putw                                                     function
        Write an integer value to the output buffer.
        _________________________________________________________________


        Calling Sequence

        #include <stdio.h>
        FILE *fp;
        int num;
        putw(num, fp);


          where   num is an integer variable.
                  fp is a pointer to a FILE stream.



        Description

        The putw function puts an integer value into the output buffer.
        See the "Input/Output Functions and Macros" section of Chapter 1
        for buffering information on the putw function.


        Returns

        The putw function returns 0 if there was no error; it returns -1
        if an error occurred.


        Related Functions

        See also the getw, putc, and puts functions.


        Example

        /* Program test for the putw() function */

        #include <stdio.h>

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

        main(argc, argv)
        int     argc;
        char   *argv[];
        {
            fp = fopen(argv[1], "w");



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





                                                                 putw(3C)



            for(c = 0 ; c < 6 ; c++) {
                putw(c, fp);
                sum += c;
            }
            printf("%d = sum of integers in %s.\n", sum, argv[1]);
            printf("Number of integers:  %d\n", c++);
        }

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

        0 1 2 3 4 5

        generates the output

        15 = sum of integers in input_nos.
        Number of integers: 6





































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



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