I have a structure and want to increase an array size whenever SendMessage function calls
struct MQStruct {
wchar_t *serviceName;
int durability;
int msgType;
int msgHeader;
wchar_t *msgId;
wchar_t *payload;
int payloadSize;
int ttl;
int priority;
}MQStructObj[1];
int SendMessage(wchar_t *serviceName, int durability, int msgType, int msgHeader, wchar_t *msgId, wchar_t *payload, int payloadSize, int ttl, int priority) {
//Want to add one more array object and also preserve data of previous
MQStructObj[MAX+1]
return 0;
}
In C you will have to deal with dynamic memory (i.e allocate the array using
malloc(), then take care to callfree()when you stop using it etc.) yourself, and possibly userealloc()to grow an allocation.In C++ the problem is already solved for you and you have
std::vector. You may callpush_backto add elements dynamically to it.