.dat file

This is a discussion on .dat file within the C++ Programming forums, part of the General Programming Boards category; can anyone please tell me how to create a normal file with the .dat extension because i want to save ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    13

    .dat file

    can anyone please tell me how to create a normal file with the .dat extension because i want to save it as a binary file? thanks.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    interestingly enough the extension name seems to indicate to the user more information than to the computer. .dat is the same as any other extension as far as I know. To store stuff as binary in a .txt file or a .dat file you can use ios::binary instead of the default output mode for ofstreams or fstreams which is text. Likewise you can store stuff as text in .dat file if you wish by using the default output mode of output streams.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    The extension is irrelevant, just open a file for writing with .dat at the end:
    Code:
    ofstream out ( "filename.dat", ios_base::binary );
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. how to convert a text file to a .dat file
    By Linette in forum C++ Programming
    Replies: 11
    Last Post: 02-25-2002, 04:58 AM

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