Friday 15 February 2013

arrays - Table of struct allocate C -


Type-ff structure {char * word; Four * translation; Word * next; word}; Typify structure list_translator

I have to do something like this

  LISTENCLUB tab [5]; But dynamic allocation I can not help it? = "Text"> 

When you are given the hints to the structures, you need to think about the memory allocation in the layers. The best thing to start at the highest level in this case works best so start:

  LISTEN_TEXT tab [5]; Here you are saying that you want a table of  p  LISTS  formations  
  LISTLIST * tab;  

Then to allocate it, you have to decide how big it is.

  Tab = Molec (size (LISTA_TLUMACZEN) * 5);   

If you want to be especially safe then the malloc parameter is not outside the category that you can use: = (NUMBER_OF_ELEMENTS

We now have your tab [5] dynamic data declaration Allocated equivalents are note that this is a table of LIST formations, then the amount allocated to memory is the size of the product and structure.

Your LISTA_TLUMACZEN Structure There is also another structure with more suggestions in an indicator. You can allocate the same kind of logic or after those really need only when the program needs them and to free them when they need it now (Which is the reason for having dynamic allocation). If all you have is pre-assigned malloc then there is something and you declare everything as small, as well as stable.

No comments:

Post a Comment