home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011120b < prev    next >
Text File  |  1992-09-14  |  473b  |  29 lines

  1. /* append.c:    Append a formatted string to another string */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdarg.h>
  6.  
  7. char *append(char *s, char *fmt, ...)
  8. {
  9.     if (s && fmt)
  10.     {
  11.         va_list args;
  12.         va_start(args,fmt);
  13.         vsprintf(s+strlen(s),fmt,args);
  14.         va_end(args);
  15.     }
  16.     return s;
  17. }
  18.  
  19. main()
  20. {
  21.     char s[81] = "We're";
  22.     append(s," number %d!\n",1);
  23.     puts(s);
  24.     return 0;
  25. }
  26.  
  27. Output:
  28. We're number 1!
  29.