clearc_c |
Table of contents
Procedureclearc_c ( Clear a two-dimensional character array ) void clearc_c ( SpiceInt ndim, SpiceInt arrlen, void * array ) AbstractFill a two-dimensional character array with blank strings. Required_ReadingNone. KeywordsARRAY ASSIGNMENT Brief_I/OVARIABLE 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_Inputndim 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_Outputarray 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. ParametersNone. Exceptions1) 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. FilesNone. ParticularsNone. ExamplesThe 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 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) Version-CSPICE Version 1.0.0, 20-SEP-2021 (JDR) Index_Entriesclear a character array |
Fri Dec 31 18:41:02 2021