Thread: Writing records to a .dat file

  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, 03:58 PM
  3. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02: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, 07:51 PM