主要内容

传递字符串参数示例

stringtoupper功能

stringtoupper功能在shrlibsample.库将输入参数中的字符转换为大写。输入参数,char,C指向字符串。

exported_function char * stringtoupper(char *输入){char * p =输入;如果(p!= null)(* p!= 0)* p ++ = toupper(* p);返回输入;}

函数签名stringtoupper如下表所示。马铃薯®映射C指针类型(char)进入cstring.因此,您可以将Matlab字符数组传递给该函数。

返回类型 名称 争论
[cstring,
cstring]
stringtoupper (CString)

将MATLAB字符数组转换为大写

此示例显示如何传递Matlab字符数组str.到一个c函数,stringtoupper

str ='这是一个混合案例字符串';

加载包含的库stringtoupper功能。

如果不是(libisloaded('shllibsample'))AddPath(FullFile(MatlaBroot,'extern'“例子”'shrlib'))LoadLibrary('shllibsample'结束

通过str.函数。

res = calllib('shllibsample''stringtoupper',str)
res ='这是一个混合案例字符串'

输入参数是指向键入的指针char。但是,Matlab字符数组不是指针,所以stringtoupper函数不修改输入参数,str.

str.
str ='这是一个混合案例字符串'

相关主题