473,320 Members | 1,939 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,320 software developers and data experts.

Modify files in C++

Hi,
I have worked with C++ off and on, but I am not sure how this must be
done. I need to modify some of the text in certain files. Specifically
I need to search for a certain word, and modify that word i.e. Change
it to some other shorter word.
I dont think that I can declare a buffer, because it may happen that
these files may be too big.

I hope someone has some ideas how this might be done.
Regards,
Rio

Jul 23 '05 #1
2 1661
ca******@yahoo.com wrote:
I have worked with C++ off and on, but I am not sure how this must be
done. I need to modify some of the text in certain files. Specifically
I need to search for a certain word, and modify that word i.e. Change
it to some other shorter word.
I dont think that I can declare a buffer, because it may happen that
these files may be too big.

I hope someone has some ideas how this might be done.


The usual approach to this is to open your file for reading, open another
file for writing, start copying until you encounter the string you need
replaced, read the original, write the replacement, then proceed with your
copying until the source file is all copied. Then upon successful closing
of both files, rename (or delete) the original and rename the temporary
file so that it has the name of the original before the operation.

Nothing language specific in all this.

V
Jul 23 '05 #2
Thanks Victor. I was hoping if there were some better way of doing
this. Thank you for your help.
Regards,
Rio

Jul 23 '05 #3

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

Similar topics

0
by: Chris McKeever | last post by:
I am trying to modify the Mailman Python code to stop mapping MIME-types and use the extension of the attachment instead. I am pretty much clueless as to what I need to do here, but I think I have...
4
by: pmud | last post by:
Hi I have a website (ASP.NET project using C# ) which is already put up on the server. I need to make some modification to some web pages.So the project files were copied to the a different server...
0
by: David Oteo | last post by:
Hi, We have developed an application for Pocket PC devices using Compact Framework. Then we have packaged it in several CAB files that users can download from a web server and install directly...
0
by: Egil Hansen | last post by:
Hi all I need to create, read and modify .url files (those Windows puts in your Favorites dir). How do I do that best? Creating should be somewhat easy, as .url files seems to be clear text...
5
by: Sandra-24 | last post by:
Is there a way in python to add the items of a dictionary to the local function scope? i.e. var_foo = dict. I don't know how many items are in this dictionary, or what they are until runtime. ...
2
by: Daniel Mark | last post by:
Hello all: I installed IPython on my XP machine today and find that my sys.path has been changed as follows:
7
by: Frank | last post by:
Years ago I wrote a program to read .lnk files, modify the data and rewrite the file. I modified it slightly and used it for .pif files. I can't find it nor can I find the API calls I used. ...
3
by: raghu sunkara | last post by:
Hi, How Can i Change or Modify Embedded String Resource In An Assembly. I Need To Modify Embedded String Resource In An Assembly. Please Help Me. Thanks Raghu.
4
by: Alan Silver | last post by:
Hello, Is it possible to modify the templates that come with VS2005? I have searched all over the place, but can't find them anywhere. I know I can make my own, but I would like to know if I can...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.