I've been looking at lots of examples, but i can't seem to write variables to a .DAT file in Dev-c++. Can anyone show me an example on hoow to do this?
I've been looking at lots of examples, but i can't seem to write variables to a .DAT file in Dev-c++. Can anyone show me an example on hoow to do this?
Can you write variables to any other file? A dat file is no different (the file extension doesn't really matter, they are there just to associate certain files with a particular program, e.g bmp->Paint)
Code:std::ofstream fout("datafile.dat"); fout << myvariable;
Does that work in an app?
what do you mean?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
???Originally Posted by Xinco
Is your question how to write to a file or how to write to a *.dat file? If it is the former you should try to find a tutorial on file input/output with C++. If it's the latter, you do it the same you'd write to a *.txt file...
I meant an app(.exe) where the user enters a variable and the app saves this variable to a .dat file
What do you mean by "the user enters a variable"? Basically, the file extension only means what you make it out to be. Treat a file named "filename.dat" as you would a file named "filename", and proceed as usual.I meant an app(.exe) where the user enters a variable and the app saves this variable to a .dat file
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
See anon's first example.
Also see this tutorial: http://www.cprogramming.com/tutorial/lesson10.html
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.