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: