home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stddef.h>
- #include <string.h>
-
- int
- main ()
-
- {
- char *text = "abcdefghijklmnopqrstuvwxyzabcdefghi";
-
- printf ("Text = '%s'\n", text);
-
- puts ("strchr\n------\n");
- printf ("found 'a' at %d\n", strchr (text, 'a') - text);
- printf ("found 'z' at %d\n", strchr (text, 'z') - text);
- printf ("found '\\0' at %d\n", strchr (text, '\0') - text);
-
- puts ("\n\nstrrchr\n------\n");
- printf ("found 'a' at %d\n", strrchr (text, 'a') - text);
- printf ("found 'z' at %d\n", strrchr (text, 'z') - text);
- printf ("found '\\0' at %d\n", strrchr (text, '\0') - text);
-
- puts ("\n\nstrichr\n------\n");
- printf ("found 'A' at %d\n", strichr (text, 'A') - text);
- printf ("found 'Z' at %d\n", strichr (text, 'Z') - text);
- printf ("found '\\0' at %d\n", strichr (text, '\0') - text);
-
- puts ("\n\nstrrchr\n------\n");
- printf ("found 'A' at %d\n", strrichr (text, 'A') - text);
- printf ("found 'Z' at %d\n", strrichr (text, 'Z') - text);
- printf ("found '\\0' at %d\n", strrichr (text, '\0') - text);
-
- return 0;
- }
-