This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mxArrayToString (C)

Array to string

C Syntax

#include "matrix.h"
char *mxArrayToString(const mxArray *array_ptr);



Pointer to mxCHAR array.


C-style string. Returns NULL on failure. Possible reasons for failure include out of memory and specifying an array that is not an mxCHAR array.


Call mxArrayToString to copy the character data of an mxCHAR array into a C-style string. The C-style string is always terminated with a NULL character and stored in column-major order.

If the array contains multiple rows, the rows are copied column-wise into a single array.

This function is similar to mxGetString, except that:

  • It does not require the length of the string as an input.

  • It supports both multi-byte and single-byte encoded characters. On Windows® and Linux® platforms, the default encoding is specified by the user locale setting.

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


See the following examples in matlabroot/extern/examples/mex.

See the following examples in matlabroot/extern/examples/mx.

Introduced before R2006a

Was this topic helpful?