MATLAB Application Program Interface
  Go to function:
    Search    Help Desk 
mxArrayToString    Examples   See Also

Convert arrays to strings

C Syntax

Arguments

array_ptr
  Pointer to a string mxArray; that is, a pointer to an mxArray having the mxCHAR_CLASS class.

Returns

A C-style string. Returns NULL on out of memory.

Description

Call mxArrayToString to copy the character data of a string mxArray into a C-style string. The copied C-style string starts at buf and contains no more than buflen-1 characters. The C-style string is always terminated with a NULL character.

If the string array contains several rows, they are copied, one column at a time, into one long string array. This function is similar to mxGetString, except that:

mxArrayToString does not free the dynamic memory that the char pointer points to. Consequently, you should typically free the string (using mxFree) immediately after you have finished using it.

Example

Use mxArrayToString to convert the data from a string array into a C string named buf:

For an additional example, see mxarraytostring.c in the mx subdirectory of the examples directory.

See Also

mxCreateCharArray, mxCreateCharMatrixFromStrings, mxCreateString, mxGetString



[ Previous | Help Desk | Next ]