Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

index(3C)

memchr(3C)

strchr(3C)

strrchr(3C)



rindex(3C)                     DG/UX 5.4R3.00                     rindex(3C)


NAME
       rindex - search for the last occurrence of a character in a string

SYNOPSIS
       #include <string.h>

       char *search, *rindex(), *result;
       int c;
       ...
       result = rindex(search, c);

   where:
       search  The string to inspect
       c       The character (casted to an int) you want to match

DESCRIPTION
       Use the rindex function to find the last occurrence of a specified
       character (which is casted to an int) in a string.  This function is
       the same as the strrchr function.

       The include file string.h defines this function.

EXAMPLE
       /* Program test for the rindex() function */

       #include <string.h>
       #include <stdio.h>
       #define MAX     80

       char  c, string[MAX], *rindex();
       int   result, i = 1;

       main(argc, argv)

       int    argc;
       char  *argv[];
       {
           printf("Character template?\n");
           scanf("%c", &c);
           while (i < argc) {
               sprintf(string, "%s", argv[i]);
               if ((result = rindex(string, (int) c)) == NULL)
                   printf("Character '%c' does not occur in \n\t'%s'\n",
                   c, string);
               else
                   printf("Last occurrence of '%c' in\n\t'%s'\nat %o.\n",
                   c, string, result);
               i++;
           }
       }

       A call to the program test with the strings element, digital, and
       execute generates the output




Licensed material--property of copyright holder(s)                         1




rindex(3C)                     DG/UX 5.4R3.00                     rindex(3C)


       Character template?
       e
       Last occurrence of 'e' in
               'element'
       at 34000023362.
       Character 'e' does not occur in
               'digital'
       Last occurrence of 'e' in
               'execute'
       at 34000023364.

       (The locations will vary with execution.)

RETURNS
       The rindex function returns NULL if the character does not occur in
       the string.  Otherwise it returns a pointer to the last occurrence of
       the character.

SEE ALSO
       index(3C), memchr(3C), strchr(3C), strrchr(3C).





































Licensed material--property of copyright holder(s)                         2


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026