I'm trying to write a function, with a variable number of integer/int array parameters, that concatenates all the elements into a single 1-dimensional array. I'm struggling with one of the two scenarios where current_item turns out to be an array instead of just an integer. How can I access the individual elements of this array and assign them to pOutList?
typedef unsigned short WORD;
int PinListJoin(WORD * pOutList, ...) {
int index=0;
boolean isArray = false;
va_list next_item;
va_start(next_item, pOutList);
WORD current_item = va_arg(next_item, WORD);
int current_item_size = sizeof(current_item) / sizeof(WORD);
if (current_item_size > 1) {
isArray = true;
for (int pinidx = 0; pinidx < current_item_size; pinidx++) {
pOutList[index] = current_item;
index++;
}
}
else {
isArray = false;
pOutList[index] = current_item;
index++;
}
va_end(next_item);
return(current_item_size);
}
No comments:
Post a Comment