Writing records to a .dat file

This is a discussion on Writing records to a .dat file within the C++ Programming forums, part of the General Programming Boards category; Hi, Straightforward question: how do I write an array of records (structs) to a file? And then how do I ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    71

    Writing records to a .dat file

    Hi,

    Straightforward question: how do I write an array of records (structs) to a file? And then how do I retrieve structs from a file (in a different program) to output them?

    Thanks

    Linette

  2. #2
    junior member mix0matt's Avatar
    Join Date
    Aug 2001
    Posts
    144
    straightforeward answer:

    show some effort. your gonna learn jack otherwise....

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    You can use <stdio.h> and use FILE structs which have a bunch of functions such as fread and fwrite which are good for writing data in binary mode.
    You could also use fget* and fscanf to get text input

    If you want to go OO then use <fstream> and ifstream's and ofstream's

    http://www.cplusplus.com/ and http://www.cplusplus.com/ref/ are some good starting points for references
    so is www.google.com

    If you any questions on specifics of using them ask away

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM
  3. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM
  4. writing data(adding new records) to the input file
    By ayesha in forum C++ Programming
    Replies: 1
    Last Post: 11-21-2001, 06:51 PM

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