Skip to main content
GameDev.net gamedev.net
🔒 Locked

Open a .dat file w/ notepad?

Started by Acid rain Apr 4, 2007 at 10:50 PM 6 replies 7.1k views
Original Post
Acid rain
Acid rain
Howdy, How do I write a .dat file(data file containing data like classes for a game) using ofstream and fstream and then being able to open it with windows NOTEPAD and edit it? As if it were a .txt file.
------------------------------Trust me, I do this all the time.
Sneftel
Sneftel
Moved to For Beginners. Acid rain, please make an effort to post your threads in the right forum to begin with.
slymr
slymr
Um...
1. you right click on icon
2. you press open
3. you press select program from list
4. choose notepad from the list
5. press ok
slymrHopefully game is in progress.
Hodgman
Hodgman
Is ".dat" your own file-format for your own game, or are you asking how to edit a particular game file format?

Have you attempted this yet, if so what part are you having trouble with?

  ofstream file;  file.open ("example.dat");  file << "data data data" << endl;  file.close();


start->run->notepad->ok->file->open->Files of type: All Files->example.dat->ok
wodinoneeye
wodinoneeye
Quote:
Original post by Acid rain
Howdy,

How do I write a .dat file(data file containing data like classes for a game) using ofstream and fstream and then being able to open it with windows NOTEPAD and edit it? As if it were a .txt file.




You are talking about serializing class objects (including pointers to other objects??) so that they are human readable (and possibly being read back in and reconstututed by your program??)


Or is your data more like an array of records of flat data records of simple types like INTs/FLOATs/STRINGs.


You can drag a .dat file onto a Notepad shortcut and it will open it as if its a .txt You could also set for the .dat file extension, Notepad.exe
to be the program that gets invoked.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
Acid rain
Acid rain
O.K. Sorry I couldn't post for while.....

Anyway, I am writing data like classes and variables and stuff to teh .dat file. I want to open teh file in notepad and look at teh variables in teh class so I can edit them. Is there a way to do this?
------------------------------Trust me, I do this all the time.
Antheus
Antheus
Quote:
Original post by Acid rain
O.K. Sorry I couldn't post for while.....

Anyway, I am writing data like classes and variables and stuff to teh .dat file. I want to open teh file in notepad and look at teh variables in teh class so I can edit them. Is there a way to do this?


Yes, by opening the file in notepad. It's just that contents won't make sense.

This is why there are two general formats: human readable (html, xml, .ini, .dxf) and machine readable (exe, dll, dat, perl, ...).

If you write variables to binary file, then they are machine readable only, and even then only by the same type of machine that wrote it. A Mac isn't able to read such data produced on PC.

This is where terms like serialization come into play.

There are some editors which allow you to specify the layout of the file and then edit it.

martin_bfg10k
martin_bfg10k
If your .dat file has binary data, you should use an Hexa editor for edit it, because if you save any change with notepad, some of your data will be corrupt.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.