memory allocation

This is a discussion on memory allocation within the C Programming forums, part of the General Programming Boards category; My program creates a binary file(bin_file.bin). Everytime the program is executed, I make changes to this struct (my_struct1)such as modifying ...

  1. #1
    afotoohi
    Guest

    memory allocation

    My program creates a binary file(bin_file.bin). Everytime the program is executed, I make changes to this struct (my_struct1)such as modifying the variables inside the struct. I also may need to add more structs(my_struct2 and my_struct3) at the end of the original struct (my_struct1). Once the program finishes execution, all the structs are to be contigeous and saved to the file (bin_fil.bin).

    I am not sure what system calls I am supposed to make to make sure that my_struct1, my_struct2 and my_struct 3 are saved to the file contigeously so when I execute my program in the future I will also have access to the data not just in my_struct1 but also to my_struct2 and my_struct3.

    You input is greatly aprreciated.

    You can email me at arash_fotoohi@yahoo.com

    Kind Regards,
    Arash

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    You will want to look at:
    fwrite()
    And do something like:
    Code:
    fwrite((const char*)&my_struct1,1,sizeof(my_struct1),f);
    gg
    Last edited by Codeplug; 03-04-2003 at 09:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory allocation question
    By dakarn in forum C Programming
    Replies: 11
    Last Post: 12-01-2008, 10:41 PM
  2. Dynamic memory allocation.
    By HAssan in forum C Programming
    Replies: 3
    Last Post: 09-07-2006, 05:04 PM
  3. Dynamic memory allocation...
    By dicorr in forum C Programming
    Replies: 1
    Last Post: 06-24-2006, 03:59 AM
  4. C memory allocation to c++
    By markucd in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2005, 04:56 AM
  5. Understanding Memory Allocation
    By Ragsdale85 in forum C Programming
    Replies: 7
    Last Post: 10-31-2005, 07:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21