Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ repeat(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                               repeat(3C)



        _________________________________________________________________
        repeat                                                   function
        Replicate a string within a character array.
        _________________________________________________________________


        Calling Sequence

        char *repeat(), *result, *string, *ptr;
        int ntimes;
        ptr = repeat(result, string, ntimes);


          where   result is a pointer to a character string to receive
                  the result.
                  string is a pointer to a character string ending in
                  the null character ( 00).
                  ntimes is an integer specifying the number of times
                  to repeat the string in the result.



        Description

        Use the repeat function to duplicate a specified string any
        number of times within a character array.


        Returns

        The return value is the pointer to the result.


        Related Functions

        See also the strcat and strcpy functions.


        Example

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

        #define MAX 136

        char  istring[MAX], ostring[MAX], *strcpy(), *repeat();
        int   i;

        main(argc, argv)

        int    argc;
        char  *argv[];



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





                                                               repeat(3C)



        {
            strcpy(istring, argv[1]);
            i = atoi(argv[2]);
            printf("\tYou want to repeat\n%s\n\t%d times?",
            istring, i);
            repeat(ostring, istring, i);
            printf("  Here it is:\n%s\n", ostring);
        }

        A call to the program test with

        x test Copyme! 6

        generates the output

        You want to repeat
        Copy_me!
        6 times? Here it is:
        Copy_me!Copy_me!Copy_me!Copy_me!Copy_me!Copy_me!



































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



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