Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. save structure in file

save structure in file

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MKC002
    wrote on last edited by
    #1

    I have some structure like struct abc{ int x; char y; DWORD z; __int64 a; char data[250]; } I have this structure in some tree and i want to save tree contents in a file. Later i want read this file and fill the tree is there any library available for that? or is there any simple and fast way to do this please sugget

    A C 2 Replies Last reply
    0
    • M MKC002

      I have some structure like struct abc{ int x; char y; DWORD z; __int64 a; char data[250]; } I have this structure in some tree and i want to save tree contents in a file. Later i want read this file and fill the tree is there any library available for that? or is there any simple and fast way to do this please sugget

      A Offline
      A Offline
      Aescleal
      wrote on last edited by
      #2

      In C you'd use fread and fwrite and in C++ you'd use std::istream::read and std::ostream::write to save plain old data (POD) structures without pointers to a file. All the functions I've mentioned read and write raw bytes so if you want a human readable file you'll have to use something else e.g. use formatted I/O in C and the stream insertion/extraction operators in C++. Cheers, Ash

      modified on Monday, January 31, 2011 4:38 AM

      1 Reply Last reply
      0
      • M MKC002

        I have some structure like struct abc{ int x; char y; DWORD z; __int64 a; char data[250]; } I have this structure in some tree and i want to save tree contents in a file. Later i want read this file and fill the tree is there any library available for that? or is there any simple and fast way to do this please sugget

        C Offline
        C Offline
        Cool_Dev
        wrote on last edited by
        #3

        simplest way are fwrite and fread.
        WriteFile and ReadFile APIS are another options. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups