File:  [MW Coherent from dump] / coherent / a / usr / man / ALL / rindex
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:34 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent



rindex()                 String Function                 rindex()




Find a character in a string

cchhaarr *rriinnddeexx(_s_t_r_i_n_g, _c) cchhaarr *_s_t_r_i_n_g; cchhaarr _c;

rindex scans string for the last occurrence of character c.  If c
is found,  rindex returns a pointer  to it.  If it  is not found,
rindex returns NULL.

***** Example *****

This example uses rriinnddeexx to help  strip a sample file name of the
path information.


#include <stdio.h>
#define PATHSEP '/' /* path name separator */



extern char *rindex();
extern char *basename();



main()
{



    printf("Before massaging: %s\n", testpath);
    printf("After massaging: %s\n", basename(testpath));
}



char *basename(path)
char *path;
{
    char *cp;
    return (((cp = rindex(path, PATHSEP)) == NULL)
                     ? path : ++cp);
}


***** See Also *****

index(), string functions

***** Notes *****

This  function is  identical to  the  function strrchr,  which is
described in the ANSI standard.




COHERENT Lexicon                                           Page 1




rindex()                 String Function                 rindex()



COHERENT includes  strrchr in  its libraries.  It  is recommended
that it  be used instead of rindex so  that programs more closely
approach strict conformity with the ANSI standard.






















































COHERENT Lexicon                                           Page 2



unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.