I have a struct PACKET which contains two int fields. How would I declare a dynamic array of PACKETs? I will be adding to the array an unknown number of times in the main…that is why I need it to be dynamically sized.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Encapsulate your dynamic array implementation with malloc/realloc in a .h/.c file pair for easier use.
If memory space is no issue, you can do the memory allocation in blocks, instead of at every addition of PACKETs and speed up the average addition.