Thursday, July 9, 2009

How to create dynamic array in c?

i want to create a dynamic array in c,because i want to get all files and folders from one path,that path contains more files and folders..so i need dynamic array in c.

How to create dynamic array in c?
Hi,


Yes u can design a Linked List. This can grow at run time. As long as u keep on reading file and folderls u can add them to linked list.


It is declared using a structure. Like this





struct filefolder


{


char filename[10];


char foldername[10];


struct filefolder *nextnode;


};





The last item in the above structure is a link to next structure.





The Linked List is like a train where each coach is linked with the next coach by a link. Starting from the engine u can go up to last coach.





U have to preserve the address of the first node. So with the address of the first node u can go up to the last node of the Linked List.
Reply:You can use a dynamic link of nodes. That can be considered an array? a little hard to implement it on C probably with the Struct function.

statice

No comments:

Post a Comment