home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / CLIBS / STRING / TEST / STRTST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-29  |  1.0 KB  |  31 lines

  1. char *msga = "hi david";
  2. char *msgb = "hello";
  3. char *msgc = "hi david2";
  4. main()
  5. {
  6.     char lbuf[200];
  7.     int i;
  8.     printf("strcpy: '%s'\n",STRCPY(lbuf,msga));
  9.     printf("strcpy: '%s'\n",lbuf);
  10.     printf("strcat: '%s'\n",STRCAT(lbuf,msgb));
  11.     printf("strcat: '%s'\n",lbuf);
  12.     printf("strlen: %d\n",STRLEN(msga));
  13.     printf("strcmp: %d\n",STRCMP(msga,msgb));
  14.     printf("strcmp: %d\n",STRCMP(msgb,msga));
  15.     printf("strcmp: %d\n",STRCMP(msga,msga));
  16.     printf("strcmp: %d\n",STRCMP(msga,msgc));
  17.     printf("strcmp: %d\n",STRCMP(msgc,msga));
  18.     printf("strchr: %s\n",STRCHR(msga,'d'));
  19.     printf("strrchr: %s\n",STRRCHR(msgb,'l'));
  20.     for (i=0; i<200; i++) lbuf[i] = 0;
  21.     for (i=0; i<10; i++) lbuf[i] = 0x33;
  22.     printf("strncpy: %s\n",STRNCPY(lbuf,msga,3));
  23.     printf("strncat: %s\n",STRNCAT(lbuf,msgb,4));
  24.     for (i=0; i<200; i++) lbuf[i] = 0x34;
  25.     STRNCPY(lbuf,msgb,10);
  26.     for (i=0; i<200; i++) printf("%x",lbuf[i]);
  27.     printf("\n");
  28.     printf("strncmp: %d\n",STRNCMP(msga,msgb,1));
  29.     printf("strncmp: %d\n",STRNCMP(msga,msgb,2));
  30.     printf("strncmp: %d\n",STRNCMP(msgb,msga,2));
  31. }