next up previous 264
Next: astStringArray - Create an array of C strings from an array of characters
Up: AST Memory Management and Utility Functions
Previous: astStore - Store data in dynamically allocated memory


astString - Create a C string from an array of characters

Description:
This function allocates memory to hold a C string and fills the string with the sequence of characters supplied. It then terminates the string with a null character and returns a pointer to its start. The memory used for the string may later be de-allocated using astFree.

This function is intended for constructing null terminated C strings from arrays of characters which are not null terminated, such as when importing a character argument from a Fortran 77 program.

Synopsis:
char $*$astString( const char $*$chars, int nchars )
Parameters:
chars
Pointer to the array of characters to be used to fill the string.
nchars
The number of characters in the array (zero or more).
Returned Value:
astString()
If successful, the function returns a pointer to the start of the allocated string. If the number of characters is zero, a zero-length string is still allocated and a pointer to it is returned.
Notes:
  • A pointer value of NULL is returned if this function is invoked with the global error status set or if it fails for any reason.


next up previous 264
Next: astStringArray - Create an array of C strings from an array of characters
Up: AST Memory Management and Utility Functions
Previous: astStore - Store data in dynamically allocated memory

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
24th May 2011
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2009 Science \& Technology Facilities Council