views:

80

answers:

1

i want to return wchar_t frm a function. How can i implement 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)

A: 

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);
}
Preet Sangha