Dynamically store lines of strings using C -
I want to store lines of dynamically wire using C language. For example,
sadasdasda5245sdf
fadfa6456
Fasdf90-70 = 790
The number of such rows and the length of each line can be anything. There is no way to dynamically store the whole thing.
There are many data structures that allow you to dynamically add items In order to know in advance what the maximum elements are required, there are linked lists, binary search trees, balanced trees, attempts, heaps and many more. Similarly, there are several ways of dynamically allocating stars of different lengths.
The easiest possible would be to use a simple one:
typedef struct _node {struct _node * next; Four * values; } Node_t;
Keep track of head , the first item in the list, and the next node in each next field indicates. For example, to cross the list, you will type something like this:
currentNode = head; While (currentNode! = NULL) {/ currentNode-> Do something with value * / currentNode = currentNode->; next; }
Without knowing what you want to do, in particular, I can not really make any better suggestions.
What action do you want to take on your data often? Are you just going through strings, searching for strings, adding and removing the string?
Comments
Post a Comment