Thread: How to write and read object data from a file ?

  1. #1
    Registered User
    Join Date
    Jun 2017
    Posts
    9

    How to write and read object data from a file ?

    Hello there
    I am trying to make a simple student database program. I have done this before with C. Now want to do this with C++ using class. In C I have stored structure data by using fwrite() function. But how can I write object data (integer and string data) in C++ ? and also how can I read the object data for that file ? any example code and explanation will help me a lot

    thanks in advance.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Not yet a real C++ Programmer; but link to the serialization topic found using Google.

    Standard C++

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jun 2017
    Posts
    157
    What file format do you want to use - text or binary?

  4. #4
    Registered User
    Join Date
    Jun 2017
    Posts
    9
    @stahta01
    Thanks for the link. I think it will help. Just need to check the whole document.
    @OldGuy2
    I want to use binary format..

  5. #5
    Registered User
    Join Date
    Jul 2017
    Posts
    2
    think writing a function that prepares a 'presentable' string for the appropriate classes should do the trick. You can then call those functions with a member of the linked list.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data read and write
    By shilpac in forum C Programming
    Replies: 3
    Last Post: 12-22-2013, 11:35 PM
  2. Replies: 2
    Last Post: 01-02-2013, 11:03 PM
  3. Replies: 7
    Last Post: 12-07-2012, 10:44 PM
  4. Replies: 12
    Last Post: 06-18-2012, 08:23 AM
  5. pipe() read(), write() - more then 128Kb of data
    By chihwahli in forum C Programming
    Replies: 3
    Last Post: 11-01-2011, 04:32 AM

Tags for this Thread