Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strsave(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                              strsave(3C)



        _________________________________________________________________
        strsave                                                  function
        Allocate an area large enough to hold a string.
        _________________________________________________________________


        Calling Sequence

        char *string, *save, *strsave();
        save = strsave(string);


          where   string is a byte pointer to a character array,
                  terminated by a null.
                  save is a byte pointer to an allocated area
                  containing the new copy of the string.



        Description

        The strsave function performs the following:

        *    Allocates from the heap an area large enough to hold a
             specified string.

        *    Moves a copy of the string into the area.

        *    Returns a pointer to the area.  Note that this function is
             the same as strnsave, except that with strnsave you specify
             a maximum number of bytes to copy.

        The include file string.h defines this function.


        Returns

        The strsave function returns a pointer to the allocated area.  It
        returns a null if it cannot allocate the area.


        Related Functions

        See also the strnsave function.


        Example

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

        #include <string.h>



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





                                                              strsave(3C)



        #include <stdio.h>

        char  *newloc;
        int    i = 1;

        main(argc, argv)
        int    argc;
        char  *argv[];
        {
            while (i < argc) {
                newloc = strsave(argv[i]);
                printf("\tStored argv[%d] at %o.\n",
                i, newloc);
                printf("argv[%d] = '%s'\n", i, newloc);
                i++;
            }
        }

        A call to the program test with

        x test Save these strings.

        generates the output

        Stored argv[1] at 34003703760.
        argv[1] = 'Save'
        Stored argv[2] at 34003677730.
        argv[2] = 'these'
        Stored argv[3] at 34003677704.
        argv[3] = 'strings.'

        (The locations vary with execution.)






















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



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