| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
#include "matrix.h" char *mxArrayToString(const mxArray *array_ptr);
Pointer to a string mxArray; that is, a pointer to an mxArray having the mxCHAR_CLASS class.
C-style string. Returns NULL on failure. Possible reasons for failure include out of memory and specifying an mxArray that is not a string mxArray.
Call mxArrayToString to copy the character data of a string mxArray into a C-style string. 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
It does not require the length of the string as an input.
It supports multibyte character sets.
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.
See mexatexit.c in the matlabroot/extern/examples/mex folder .
For additional examples, see mxcreatecharmatrixfromstr.c and mxislogical.c in the matlabroot/extern/examples/mx folder .
mxCreateCharArray, mxCreateCharMatrixFromStrings, mxCreateString, mxGetString
![]() | mxArray (C and Fortran) | mxAssert (C) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |