|
From: Ramana K. <ra...@my...> - 2001-12-11 22:38:15
|
I know how to save to binary, which doesn't look like text if opened in
notepad or something:
#include <fstream.h>
...
int anumber = 17;
char letters[7] = "hello!";
ofstream fout("path of file");
fout.write((char*) &anumber, sizeof anumber);
fout.write((char*) &letters, sizeof letters);
fout.close()
//to retrieve data
ifstream fin("path of file");
int savednumber;
fin.read((char*) &savednumber, sizeof savednumber);
...
that's the basic principle for it, it worked for me, and some things might
not be necessary (like the (char*) for letters), I'm not sure, but including
it shouldn't hurt.
You also might need to include stdlib.h if it doesn't work
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]On Behalf Of Ian Weston
Sent: mercredi 12 décembre 2001 04:18
To: Dev...@li...
Subject: [Dev-C++] creating files
hello, i was just wondering if anyone can help me. i want to be able to save
int's to a file and maybe even chars's. the thing is i don't want it to be
in text. so does anyone know how to save it as a binary file or what have
you.
thankyou.
ian
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|