Hey all...!
I found out a nice thing while going trough a friends C++ education disk.
It was 'ofstream writedata(filnamn,ios::binary|ios::app);' though I have little knowledge what it does I am quite sure it writes / reads data in binary form. I tried to write and I wrote in binary (I think). I searched the help files in BCB 3 but found nothing about ofstream
In my previous program I stored data in plain text, which I do not like due to the fact that one can easily manipulate that file.
The program main function is to store Internet connection time in a 'user'.txt file.
One file could look like this
#0,1125 // float number, the # is to find the float number [payment per minute]
¤SEK // string, the ¤ is to find the string [currency]
2000-09-01 02 30 // date (int)hours (int)minutes, hours and minutes connected that date
2000-09-02 00 20 // date (int)hours (int)minutes, hours and minutes connected that date
First I have a function that finds either '#' or '¤' and stores value in a label (or other) or if it finds a 'date' then it will get hours and minutes in that line and store them in a totalHours / totalMinutes integer, for now I store a row in the file as a string then gets two values at specific positions,
line=(AnsiString)row; // A row in the file using while(fget(row,81,file))
hour=line[12];
hour+=line[13]; // this would result in 02 in above files first 'date' row
I am unable to use SubString;
Can anyone help me recreate the function that gets stored information form a binary file?
I not so familiar with this 'ofstream writedata(filnamn,ios::binary|ios::app);'
One last question: When a binary file is opened with ofstream, can I then search for a specific value (numeric or string)? If so, How?
All suggestions are welcome!
Thanks in advance Martin!
[sig]<p>Martin G Broman<br><a href=mailto:mgb_svea@hotmail.com>mgb_svea@hotmail.com</a><br><a href= > </a><br>DWS - Alpha Whitin Dead Wolf Society[/sig]
I found out a nice thing while going trough a friends C++ education disk.
It was 'ofstream writedata(filnamn,ios::binary|ios::app);' though I have little knowledge what it does I am quite sure it writes / reads data in binary form. I tried to write and I wrote in binary (I think). I searched the help files in BCB 3 but found nothing about ofstream
In my previous program I stored data in plain text, which I do not like due to the fact that one can easily manipulate that file.
The program main function is to store Internet connection time in a 'user'.txt file.
One file could look like this
#0,1125 // float number, the # is to find the float number [payment per minute]
¤SEK // string, the ¤ is to find the string [currency]
2000-09-01 02 30 // date (int)hours (int)minutes, hours and minutes connected that date
2000-09-02 00 20 // date (int)hours (int)minutes, hours and minutes connected that date
First I have a function that finds either '#' or '¤' and stores value in a label (or other) or if it finds a 'date' then it will get hours and minutes in that line and store them in a totalHours / totalMinutes integer, for now I store a row in the file as a string then gets two values at specific positions,
line=(AnsiString)row; // A row in the file using while(fget(row,81,file))
hour=line[12];
hour+=line[13]; // this would result in 02 in above files first 'date' row
I am unable to use SubString;
Can anyone help me recreate the function that gets stored information form a binary file?
I not so familiar with this 'ofstream writedata(filnamn,ios::binary|ios::app);'
One last question: When a binary file is opened with ofstream, can I then search for a specific value (numeric or string)? If so, How?
All suggestions are welcome!
Thanks in advance Martin!
[sig]<p>Martin G Broman<br><a href=mailto:mgb_svea@hotmail.com>mgb_svea@hotmail.com</a><br><a href= > </a><br>DWS - Alpha Whitin Dead Wolf Society[/sig]