Thread: Memory in C

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    116

    Question Memory in C

    I have this code:
    Code:
    struct List{
    int info;
    int member;
    }
    int main(){
    struct List *tmp;
    tmp=calloc(sizeof(List));
    }
    I want to ask is: when I'm call tmp=calloc(sizeof(List)), It will find two consecutive memory block and create info and member or It will find two different memory block to create them.

    thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    It will "find" one block that is the size of a List object.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    If you are asking if they are stored together the answer is yes. As Tabstop points out it's one object (a struct(ure)) not two variables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic memory and realloc(), freeing memory
    By C_Sparky in forum C Programming
    Replies: 6
    Last Post: 10-06-2010, 07:55 PM
  2. Replies: 12
    Last Post: 04-11-2010, 07:14 AM
  3. Allocate memory inside allocated memory block?
    By Heidi_Nayak in forum C Programming
    Replies: 14
    Last Post: 04-15-2009, 04:19 PM
  4. Finding memory address using memory pattern
    By MindWorX in forum C++ Programming
    Replies: 1
    Last Post: 05-25-2008, 07:20 AM
  5. Replies: 2
    Last Post: 09-28-2006, 01:06 PM