Thread: Dat files

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    24

    Dat files

    It might be a silly question but I have to ask it.
    It is about dat files one friend of mine said to me that dat files are normal exe files but the ending was changed.

    When this isn't true how can I creat dat files and how i link them to my game (like normal exe files with spawnl(bla,dsd.exe,bla))

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    There is no specific layout of a dat file, it can be whatever you want. A text file, a bitmap or pure binary data suited for your datatypes. You choose.
    It's the way you handle the data that counts.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User FearOfTheDark's Avatar
    Join Date
    Jan 2003
    Posts
    31

    Binary datfile!

    To creat a binary datafile, if that's what you want:

    struct hello
    {
    int a,b,c,d;
    //What ever you want...
    }j[100];


    fstream f("c:\\hello.dat",ios:ut|ios::binary);
    for(int a=0;a<100;a++)
    f.write((char *)(lj+a),sizeof(struct hello));
    f.close();

    And to read the same datafile:

    int count=0;
    if(access("c:\\hello.dat,00))
    cout<<"The file does not exist!";
    else
    {
    fstream f("c:\\hello.dat",ios::in|ios::binary);
    while(!f.eof())
    {
    f.read((char *)(j+count),sizeof(struct hello));
    count++;
    }
    f.close();
    -We're living in a illusion!
    -Ok, if that's what you think!

  4. #4
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Well your friend was partially right, if i compiled whatever.exe and renamed it to whatever.dat, i believe it would still run.
    PHP and XML
    Let's talk about SAX

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dat files with visual C++
    By abhinavbezgam in forum C++ Programming
    Replies: 1
    Last Post: 05-20-2009, 09:55 PM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. n00b question.... dat file related
    By hobbes67 in forum C Programming
    Replies: 7
    Last Post: 06-24-2005, 11:39 AM