📄 mex_string.c
字号:
#include "matrix.h"
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
char *my_str;
int n_mystr, i;
if (nrhs!=1) mexErrMsgTxt("Wrong number of input arguments!");
if (nlhs>1) mexErrMsgTxt("Too many output arguments!");
if (!mxIsChar(prhs[0])) mexErrMsgTxt("String input is required!");
n_mystr=mxGetNumberOfElements(prhs[0])+1;
my_str=mxMalloc(n_mystr, sizeof(char));
mxGetString(prhs[0], my_str, n_mystr);
if (nlhs==1) plhs[0]=mxCreateString(my_str);
else{
for (i=0; i<n_mystr; i++) mexPrintf("%c",my_str[i]);
mexPrintf("\n");
}
mxFree(my_str);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -