home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / learn / setstr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-25  |  978 b   |  29 lines

  1. /* SETSTR.C illustrate string and memory set functions including:
  2.  *     memset           strnset         strset
  3.  */
  4.  
  5. #include <memory.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8.  
  9. char string[60] = "The quick brown dog jumps over the lazy fox ";
  10. /*                          1         2         3         4         5 *
  11.  *                 12345678901234567890123456789012345678901234567890 */
  12. main()
  13. {
  14.     printf( "Function:\tmemset with fill character '█'\n" );
  15.     printf( "Destination:\t%s\n", string );
  16.     memset( string + 10, '█', 5 );
  17.     printf( "Result:\t\t%s\n\n", string );
  18.  
  19.     printf( "Function:\tstrnset with fill character '█'\n" );
  20.     printf( "Destination:\t%s\n", string );
  21.     strnset( string + 15, '█', 5 );
  22.     printf( "Result:\t\t%s\n\n", string );
  23.  
  24.     printf( "Function:\tstrset with fill character '█'\n" );
  25.     printf( "Destination:\t%s\n", string );
  26.     strset( string + 20, '█' );
  27.     printf( "Result:\t\t%s\n\n", string );
  28. }
  29.