开发者

How to return wchar_t from a function

开发者 https://www.devze.com 2022-12-25 09:47 出处:网络
i want to return wchar_t frm a function. How can i im开发者_如何学Pythonplement it wchar_t wcstring1[newsize1]

i want to return wchar_t frm a function. How can i im开发者_如何学Pythonplement it

wchar_t wcstring1[newsize1]

How to return "wcstring1" from a function and make it to save into another variable of same type(In another function)


i don't have a compiler to hand, but guessing the c syntax as I've not done c in a decade I reckon!

wchar_t * getdata(int size) {
 // get space...
 wchar_t * data = malloc(sizeof(wchar_t) * size);
 // put some data in...
 // .....
 return data;
}

void main(void) {
 const int newsize1= ...;
 wchar_t wcstring1[newsize1]
 wchar_t * data = getdata(newsize1);
 memcpy(wcstring1, data , sizeof(wchar_t) * newsize1);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消