K
katz911
Hello,
I've encountered a strange problem which I can't seem to explain.
I've written a simple C++ class that deals with a certian binary file.
In one of the methods there, I wish to update a file - namely to read
a certain field whose offset I know, and then write to another field,
whose offset I also know.
In order to read the data, I first use file.seekg(offset, ios::beg),
and then a read command; I've checked the variable, and this part is
executed as it should be. The problem is with the writing.
To place the head where I want it, I use a file.seekp(offset,
ios::beg) statement. After this statement, regardless of what the
value of 'offset' is, file.tellp() always returns '-1'.
The file was opened using the statement:
file.open(FileName.c_str(), ios::in | ios:ut | ios::binary)
where FileName is a string. The reading goes smoothly and returns the
correct values, so I doubt there's a problem with the actual opening
of the file.
Thanks in advance to whoever can solve the mystery!
GK
I've encountered a strange problem which I can't seem to explain.
I've written a simple C++ class that deals with a certian binary file.
In one of the methods there, I wish to update a file - namely to read
a certain field whose offset I know, and then write to another field,
whose offset I also know.
In order to read the data, I first use file.seekg(offset, ios::beg),
and then a read command; I've checked the variable, and this part is
executed as it should be. The problem is with the writing.
To place the head where I want it, I use a file.seekp(offset,
ios::beg) statement. After this statement, regardless of what the
value of 'offset' is, file.tellp() always returns '-1'.
The file was opened using the statement:
file.open(FileName.c_str(), ios::in | ios:ut | ios::binary)
where FileName is a string. The reading goes smoothly and returns the
correct values, so I doubt there's a problem with the actual opening
of the file.
Thanks in advance to whoever can solve the mystery!
GK