home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / unixlib / !UnixLib / test / c / strchr < prev    next >
Encoding:
Text File  |  1994-03-08  |  1.0 KB  |  35 lines

  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #include <string.h>
  4.  
  5. int
  6. main ()
  7.  
  8. {
  9.   char *text = "abcdefghijklmnopqrstuvwxyzabcdefghi";
  10.  
  11.   printf ("Text = '%s'\n", text);
  12.  
  13.   puts ("strchr\n------\n");
  14.   printf ("found 'a' at %d\n", strchr (text, 'a') - text);
  15.   printf ("found 'z' at %d\n", strchr (text, 'z') - text);
  16.   printf ("found '\\0' at %d\n", strchr (text, '\0') - text);
  17.  
  18.   puts ("\n\nstrrchr\n------\n");
  19.   printf ("found 'a' at %d\n", strrchr (text, 'a') - text);
  20.   printf ("found 'z' at %d\n", strrchr (text, 'z') - text);
  21.   printf ("found '\\0' at %d\n", strrchr (text, '\0') - text);
  22.  
  23.   puts ("\n\nstrichr\n------\n");
  24.   printf ("found 'A' at %d\n", strichr (text, 'A') - text);
  25.   printf ("found 'Z' at %d\n", strichr (text, 'Z') - text);
  26.   printf ("found '\\0' at %d\n", strichr (text, '\0') - text);
  27.  
  28.   puts ("\n\nstrrchr\n------\n");
  29.   printf ("found 'A' at %d\n", strrichr (text, 'A') - text);
  30.   printf ("found 'Z' at %d\n", strrichr (text, 'Z') - text);
  31.   printf ("found '\\0' at %d\n", strrichr (text, '\0') - text);
  32.  
  33.   return 0;
  34. }
  35.