473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Updating a binary file?

Hello all,

I'm having problems updating a binary file as when I open with the
flags ios::binary and ios::out the file is cleared of its data. Is
there any way I can retain its original contents and make changes to a
certain region only?

Thanks in advance,
Lanturn

Jan 1 '06 #1
4 2020
On 1 Jan 2006 07:08:09 -0800 in comp.lang.c++, "la*****@gmail.com"
<la*****@gmail.com> wrote,
Hello all,

I'm having problems updating a binary file as when I open with the
flags ios::binary and ios::out the file is cleared of its data. Is
there any way I can retain its original contents and make changes to a
certain region only?


Open with ios::in|ios::out

Jan 1 '06 #2
Hmm thanks... it seems to work but it always modifies the last variable
in the struct at the last record such that it contains a random value.
As a sidenote, is the ios::binary flag optional then?

Jan 2 '06 #3
On 1 Jan 2006 19:29:46 -0800 in comp.lang.c++, "la*****@gmail.com"
<la*****@gmail.com> wrote,
Hmm thanks... it seems to work but it always modifies the last variable
in the struct at the last record such that it contains a random value.
As a sidenote, is the ios::binary flag optional then?


No, I should have written ios::in|ios::out|ios::binary. But you
already had that part. You should open in the correct mode to be
correct, but some systems may have no actual difference between text
and binary.

What's that about random values? Mind your seekp() and seekg()s,
and post example code if you still have trouble.

Jan 2 '06 #4
Gee... thanks a lot..
It works perfectly now... It must have occurred when I opened without
the binary mode.

Jan 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
6
by: Jonathan | last post by:
I am trying to upload a new version of a file that already exists on my web site. It asks me to overwrite and I choose yes. But when I go to the web page, even a half hour after the upload, the...
9
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
2
by: Gary B via AccessMonster.com | last post by:
Hi all, Is there any way of checking if a file exists on a website? I have an autoupdate routine that runs from a clients server, but it would be useful if it could run over the internet. I'm...
15
by: slinky | last post by:
Thanks in advance fo rany help... I have an XML data file (well- formed) that I need to place into my website's app_data folder. I would like to have an .aspx form on my site that simply has two...
5
by: mechphisto | last post by:
I have a FC 7 box with PHP 5.2.4 and I'm installing mcrypt. To do that, I have to recompile PHP with the libmcrypt switches in the ./ configure. So I downloaded the latest PHP source files, and...
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
7
by: Rico | last post by:
Hello, I have a VB6 ActiveX DLL project that I use to connect to an SQL Server database. The front end that uses this DLL is written in Access XP / 2002. When I modify the ActiveX code, compile...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.