To access members of 2nd struct person, Ptr = (struct person*) malloc(n * sizeof(struct person)) allocating memory for n numbers of struct person Example: Dynamic memory allocation of structs #include Here's how you can achieve this in C programming. You may need to allocate memory during run-time. Sometimes, the number of struct variables you declared may be insufficient. personPtr->weight is equivalent to (*personPtr).weightīefore you proceed this section, we recommend you to check C dynamic memory allocation.personPtr->age is equivalent to (*personPtr).age.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |