cpos_c

Index Page cpos_c
A B C D E F G H I J K L M N O P Q R S T U V W X
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       SpiceInt cpos_c ( ConstSpiceChar    * str,
                         ConstSpiceChar    * chars,
                         SpiceInt            start  )
#### Abstract
       Find the first occurrence in a string of a character belonging
       to a collection of characters, starting at a specified location,
       searching forward.
#### Required_Reading
       SCANNING
#### Keywords
       CHARACTER
       SEARCH
       UTILITY
#### Brief_I/O
       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       str        I   Any character string.
       chars      I   A collection of characters.
       start      I   Position to begin looking for one of chars.

       The function returns the index of the first character of str
       at or following index start that is in the collection chars.
#### Detailed_Input
       str        is any character string.

       chars      is a character string containing a collection
                  of characters.  Spaces in chars are significant,
                  including trailing blanks.  The order in which
                  characters are listed is not significant.

       start      is the position in str to begin looking for one of
                  the characters in chars.  start may range from 0
                  to n-1, where n is the number of characters in str.
#### Detailed_Output
       The function returns the index of the first character of str (at or
       following index start) that is one of the characters in the string
       chars.  The returned value normally ranges from 0 to n-1, where n is
       the number of characters in str. If none of the characters is found,
       the function returns -1.
#### Parameters
       None.
#### Exceptions
       1) The error SPICE(NULLPOINTER) is signaled if either of
          the input string pointers is null.

       2) If start is less than 0, the search begins at the first
          character of the string.

       3) If start is greater than or equal to the length of the string,
          cpos_c returns -1.

       4) The function returns -1 if either of the input strings is empty.
#### Files
       None.
#### Particulars
       cpos_c is case sensitive.

       An entire family of related CSPICE routines

          cpos_c
          cposr_c
          ncpos_c
          ncposr_c
          pos_c
          posr_c

       is described in the Required Reading.
#### Examples
       Let string == "BOB, JOHN, TED, AND MARTIN...."
                      012345678901234567890123456789

       Normal (sequential) searching
       -----------------------------

          cpos_c( string, " ,",    0  ) ==  3
          cpos_c( string, " ,",    4  ) ==  4
          cpos_c( string, " ,",    5  ) ==  9
          cpos_c( string, " ,",    10 ) == 10
          cpos_c( string, " ,",    11 ) == 14
          cpos_c( string, " ,",    15 ) == 15
          cpos_c( string, " ,",    16 ) == 19
          cpos_c( string, " ,",    20 ) == -1

       start out of bounds
       -------------------

          cpos_c( string, " ,",  -112 ) ==  3
          cpos_c( string, " ,",    -1 ) ==  3
          cpos_c( string, " ,",  1230 ) == -1
#### Restrictions
       None.
#### Literature_References
       None.
#### Author_and_Institution
       N.J. Bachman    (JPL)
       W.L. Taber      (JPL)
#### Version
       -CSPICE Version 1.0.0, 15-AUG-2002 (NJB) (WLT)
#### Index_Entries
       forward search for position of character
#### Link to routine cpos_c source file cpos_c.c

    Thu Apr 16 08:57:34 2009