-
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))
-
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.
-
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::out|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();
-
Well your friend was partially right, if i compiled whatever.exe and renamed it to whatever.dat, i believe it would still run.