(Hi to all... ^_^)
I tryed theese ways:
fstream riaperto( "codici.dat", ios::out|ios::binary|ios::app);
if(riaperto.bad()){
cerr<<"errore di apertura"<<endl;
system("Pause");
}
riaperto.seekp(ios::beg);
riaperto.put(char(nbyte/256));
riaperto.put(char(nbyte%256));
^= This one writes the bytes at the end of the file (allright, it's the
"app") .
ofstream riaperto( "codici.dat", ios::out|ios::binary);
if(riaperto.bad()){
cerr<<"errore di apertura"<<endl;
system("Pause");
}
riaperto.seekp(ios::beg);
riaperto.put(char(nbyte/256));
riaperto.put(char(nbyte%256));
This one it writes at the beginning but, then, the file contains only that
tow bytes... (overwrite)
What can i do?
Thanks in advance..
Gnafu 10 2638
Gnafu wrote: (Hi to all... ^_^)
I tryed theese ways:
fstream riaperto( "codici.dat", ios::out|ios::binary|ios::app); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
^= This one writes the bytes at the end of the file (allright, it's the "app") .
ofstream riaperto( "codici.dat", ios::out|ios::binary); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
This one it writes at the beginning but, then, the file contains only that tow bytes... (overwrite)
What can i do?
Thanks in advance..
Write the new bytes you want to a temporary file, then copy the content of
the original file over. If that was successful, rename the temporary file
to the name of the original.
In article <e7*************@news.t-online.com>, ra******@t-online.de says...
[ ... ] Write the new bytes you want to a temporary file, then copy the content of the original file over. If that was successful, rename the temporary file to the name of the original.
....and hope there are no other hard links to the file --
because if there are, you now have two separate files,
and all of the other hard links point to the unmodified
file.
--
Later,
Jerry.
The universe is a figment of its own imagination.
> Write the new bytes you want to a temporary file, then copy the content of the original file over. If that was successful, rename the temporary file to the name of the original.
I wanted to not do that.... :(
Ok, thank anyway..
Jerry Coffin wrote: In article <e7*************@news.t-online.com>, ra******@t-online.de says...
[ ... ]
Write the new bytes you want to a temporary file, then copy the content of the original file over. If that was successful, rename the temporary file to the name of the original.
...and hope there are no other hard links to the file -- because if there are, you now have two separate files, and all of the other hard links point to the unmodified file.
That's one of the reasons to better use symlinks ;-)
* Rolf Magnus: Jerry Coffin wrote:
In article <e7*************@news.t-online.com>, ra******@t-online.de says...
[ ... ]
Write the new bytes you want to a temporary file, then copy the content of the original file over. If that was successful, rename the temporary file to the name of the original. ...and hope there are no other hard links to the file -- because if there are, you now have two separate files, and all of the other hard links point to the unmodified file.
That's one of the reasons to better use symlinks ;-)
Depends on the OS. Windows supports hardlinks for files, symlinks for
directories, and shortcuts (which are like symlinks but not
automatically resolved) for anything. The rename approach might be
appropriate when safety against file content destruction is important,
you're guaranteed that no other process will create that file in the
span between its deletion and recreation by your program, and efficiency
is valued more than link preservation.
I think it should be a user-selectable option.
Follow-ups to [comp.programming].
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
You'll need to put "POSIX compliant system" on your product
requirements box for doing this:
i = open ("blarg", O_WRONLY);
lseek(i, 0, SEEK_SET);
write(i, my_buffer, 2);
close(i);
Gnafu wrote: (Hi to all... ^_^)
I tryed theese ways:
fstream riaperto( "codici.dat", ios::out|ios::binary|ios::app); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
^= This one writes the bytes at the end of the file (allright, it's the "app") .
ofstream riaperto( "codici.dat", ios::out|ios::binary); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
This one it writes at the beginning but, then, the file contains only that tow bytes... (overwrite)
What can i do?
Thanks in advance..
Gnafu
please don't top-post.
hdante wrote: Yo> Gnafu wrote: (Hi to all... ^_^)
I tryed theese ways:
fstream riaperto( "codici.dat", ios::out|ios::binary|ios::app); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
^= This one writes the bytes at the end of the file (allright, it's the "app") .
ofstream riaperto( "codici.dat", ios::out|ios::binary); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
This one it writes at the beginning but, then, the file contains only that tow bytes... (overwrite)
What can i do?
u'll need to put "POSIX compliant system" on your product requirements box for doing this:
i = open ("blarg", O_WRONLY); lseek(i, 0, SEEK_SET); write(i, my_buffer, 2); close(i);
This will not insert two bytes at the beginning. Rather it overwrites the
first two bytes.
What does "top-post" mean ?
I'm sorry, I thought that's what he wanted.
Rolf Magnus wrote: please don't top-post.
hdante wrote:
Yo> Gnafu wrote: (Hi to all... ^_^)
I tryed theese ways:
fstream riaperto( "codici.dat", ios::out|ios::binary|ios::app); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
^= This one writes the bytes at the end of the file (allright, it's the "app") .
ofstream riaperto( "codici.dat", ios::out|ios::binary); if(riaperto.bad()){ cerr<<"errore di apertura"<<endl; system("Pause"); }
riaperto.seekp(ios::beg); riaperto.put(char(nbyte/256)); riaperto.put(char(nbyte%256));
This one it writes at the beginning but, then, the file contains only that tow bytes... (overwrite)
What can i do?
u'll need to put "POSIX compliant system" on your product requirements box for doing this:
i = open ("blarg", O_WRONLY); lseek(i, 0, SEEK_SET); write(i, my_buffer, 2); close(i);
This will not insert two bytes at the beginning. Rather it overwrites the first two bytes.
hdante wrote: Rolf Magnus wrote: please don't top-post. What does "top-post" mean ?
It means that you are writing your text above the text you're answering to
instead of in a chronological order. I'll quote from Alf P. Steinbach's
signature:
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
You should write your answers below the original text and directly below the
part that you are answering to. Also snip away parts that are not relevant
to your answer.
hdante <hd****@gmail.com> wrote: What does "top-post" mean ? http://en.wikipedia.org/wiki/Top_posting
Your responses should be interspersed thoughout the trimmed quoted text.
--
Marcus Kwok
Replace 'invalid' with 'net' to reply This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
I have to get this done by tonight! I have a .CSV file and a PHP file where
I am inserting the values of the CSV file into the db table.
See the results live:...
|
by: Atz |
last post by:
Hi to all !
Im using MySql front and PHP 5 for some web shop.
I didn't try it so far but i guess that the online data insertation ( accept
costs and time ) should be the same process like for...
|
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in the
selected table- If it exists, then the colums...
|
by: Abareblue |
last post by:
I have no clue on how to insert a record into access. here is the whole
thing
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
|
by: Chris Fink |
last post by:
I have setup an Oracle table which contains a blob field. How do I insert
data into this field using C# and ADO.net?
|
by: kyo guan |
last post by:
Hi :
python list object like a stl vector, if insert a object in the front or the middle of it,
all the object after the insert point need to move backward.
look at this code ( in python...
|
by: Me |
last post by:
Trying to get the current status of the insert key. Found
my.computer.keyboard.capslock, but no such item for insert key. Anyone
have some code to help. Can't figure out getkeystate. compiler...
|
by: deepaks85 |
last post by:
Dear Friends,
If I have a text file more than 8 byte or upto 100 byte, how can I insert the data of that text file into mysql table. As per as I am concern there is not any datatype more than 4...
|
by: ansuhua |
last post by:
I need save huge data in a file in byte format.Sometimes i have to insert some bytes in a special position.I use FileStream,but i can only append byte at the end of the file or rewrite data in the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |