Show us your basic attempt start to the code with [code][/code] tags.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
I've got the program
You've got a program that reads from the .dat file, so why not post that?program but I have no idea on where to start to make a .dat file.All I can figure is to make a .txt file and call it Scores.datI'm confused. As far as I know, a .dat file is just the same as any other text file. It just a name. Or do you draw a distinction?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Its been my experience that .dat files contain binary data, such as the computer's binary representation of an integer and not the ascii digits that you will find in a text file. .dat files normally can not be easily read by text editors such as Notepad.exe.
Exemple:
struct mystruct
{
int a;
long b;
float c;
double d;
};
int main()
{
myruct s
// write the structure to the file
ofstream out("mydata.dat", ios::binary);
out.write((char *)&s,sizeof(s));
out.close();
// now read the file
ifstream in("mydata.dat", ios::binary);
in.read((char*)&s,sizeof(s));
in.close();
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343