Thread: Struct with a ptr to a dynamically allocated array of other structures :(

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    null
    Join Date
    Dec 2005
    Posts
    18
    Some of the code provided by my teacher makes me doubt what I'm doing (not that I was ever sure):
    Code:
    	for( i = 0; i < db->ncountries; i++ )
    	{
    		delete_country( db->list+i );   // free mem alloc to a country
    	}
    I should be able to use that same "db->list+i" part to check the array, right? I'm just trying to find the first free element to insert my country into...
    Data structures are so much easier, but I'm stuck with these parameters!

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    95
    After that, I don't really know how to work with that array anymore. I've never read or used anything that does this
    But anyway , using calloc , the space is initializied to zero.

    to loop the array :
    Code:
    int  i;
    
    for( i = 0; i < db->ncountries; i++ )
        db->list[i] = NULL;
        /* or
        *(db->list+i) = NULL;
        */

    Why don't u post the all code ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  3. Replies: 6
    Last Post: 01-16-2007, 09:21 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM