Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
clearc_c

Table of contents
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

   clearc_c ( Clear a two-dimensional character array ) 

   void clearc_c ( SpiceInt            ndim,
                   SpiceInt            arrlen,
                   void              * array   )

Abstract

   Fill a two-dimensional character array with blank strings.

Required_Reading

   None.

Keywords

   ARRAY
   ASSIGNMENT


Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   ndim       I   Number of rows of `array' to be set to blank.
   arrlen     I   Common length of the strings in `array'.
   array      O   Two-dimensional character array to be filled.

Detailed_Input

   ndim        is the number of rows in `array' which are to be set to
               blank.

   arrlen      is the common length of the strings in `array', including
               the terminating null character.

Detailed_Output

   array       a two-dimensional character array having as minimum dimensions

                  [ndim][arrlen]

               Each of the first `ndim' rows of the two-dimensional character
               array is to be filled with blank characters up to index arrlen-2
               and null-terminated.

Parameters

   None.

Exceptions

   1)  If ndim < 1, the array is not modified.

   2)  If the `array' output string pointer is null, the error
       SPICE(NULLPOINTER) is signaled.

   3)  If the `array' output string has length less than two
       characters, the error SPICE(STRINGTOOSHORT) is signaled, since
       the output string is too short to contain one character of
       output data plus a null terminator.

Files

   None.

Particulars

   None.

Examples

   The numerical results shown for this example may differ across
   platforms. The results depend on the SPICE kernels used as
   input, the compiler and supporting libraries, and the machine
   specific arithmetic implementation.

   1) Initialize a two dimensional character array and then clear
      the first two rows.


      Example code begins here.


      /.
         Program clearc_ex1
      ./
      #include <stdio.h>
      #include <string.h>
      #include "SpiceUsr.h"

      int main( )
      {

         /.
         Local parameters.
         ./
         #define ARRSZ        22
         #define NDIM         4

         /.
         Local variables.
         ./
         SpiceChar            array  [NDIM][ARRSZ];
         SpiceInt             i;

         /.
         Initialize `array'.
         ./
         strncpy( array[0], "Element #1", 11 );
         strncpy( array[1], "Element #2", 11 );
         strncpy( array[2], "Element #3", 11 );
         strncpy( array[3], "Element #4", 11 );

         printf( "Contents of ARRAY before clearc_c:\n" );
         printf( "\n" );
         for ( i = 0; i < NDIM; i++ )
         {
            printf( "Position #%d: %s\n", (int)i, array[i] );
         }

         /.
         Clear the first 2 elements.
         ./
         clearc_c ( 2, ARRSZ, array );

         printf( "\n" );
         printf( "Contents of ARRAY after clearc_c:\n" );
         printf( "\n" );
         for ( i = 0; i < NDIM; i++ )
         {
            printf( "Position #%d: %s\n", (int)i, array[i] );
         }

         return ( 0 );
      }


      When this program was executed on a Mac/Intel/cc/64-bit
      platform, the output was:


      Contents of ARRAY before clearc_c:

      Position #0: Element #1
      Position #1: Element #2
      Position #2: Element #3
      Position #3: Element #4

      Contents of ARRAY after clearc_c:

      Position #0:
      Position #1:
      Position #2: Element #3
      Position #3: Element #4

Restrictions

   None.

Literature_References

   None.

Author_and_Institution

   J. Diaz del Rio     (ODC Space)

Version

   -CSPICE Version 1.0.0, 20-SEP-2021 (JDR)

Index_Entries

   clear a character array
Fri Dec 31 18:41:02 2021