Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rindex(3C) — DG/UX 4.30

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     rindex(3C)                 DG/UX 4.30                  rindex(3C)



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

     SYNOPSIS
          #include <string.h>

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


          where   search is the string to inspect.
                  c is the character you want to match.


     DESCRIPTION
          Use the rindex function to find the last occurrence of a
          specified character in a string.  This function is the same
          as the strrchr function.

          The include file string.h defines this function.

     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
          See also the index, memchr, strchr, and strrchr functions.

     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 = strrchr(string, c)) == NULL)
                      printf("Character '%c' does not occur in \n\t'%s'\n",
                      c, string);



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





     rindex(3C)                 DG/UX 4.30                  rindex(3C)



                  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

          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.)

































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



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