home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / c / help.arc / UNARGV.C < prev    next >
C/C++ Source or Header  |  1988-03-10  |  685b  |  33 lines

  1. #define UNARGV_C
  2. #define LINT_ARGS
  3. #include <stdio.h>
  4.  
  5. /*    UNARGV.C    Concatantate all argv entries into a single
  6.  *            string.
  7.  */
  8.  
  9. int    unargv( argc, argv, dest, maxcount )
  10. char          **argv, *dest;
  11. register int  maxcount;
  12. {
  13.     /*    Turn argv into a single string, with a single ' ' seperating
  14.      *    each entry. maxcount is the maximum size of dest. Return
  15.      *    the number of characters put into dest.
  16.      */
  17.  
  18.     register char    *src;
  19.     char        *sdest = dest;
  20.  
  21.     while( --argc >= 0  && maxcount > 0 )
  22.     {
  23.         for( src = *argv++; *src && --maxcount > 0; )
  24.             *dest++ = *src++ ;
  25.  
  26.         if( --maxcount > 0  &&  argc > 0 )
  27.             *dest++ = ' ';
  28.     }
  29.  
  30.     *dest = 0;
  31.     return( dest - sdest );
  32. }
  33.