Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > programmatically replace characters in a text file?

Reply
Thread Tools

programmatically replace characters in a text file?

 
 
cheesywillie@gmail.com
Guest
Posts: n/a
 
      04-15-2007
How would this be done? For example find every "a" and replace them
with a "b".

Sorry if i am not being descriptive enough, but i don't know how else
to phrase the question. If you need any additional information just
ask.

Thanks for reading.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      04-15-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> How would this be done? For example find every "a" and replace them
> with a "b".
>
> Sorry if i am not being descriptive enough, but i don't know how else
> to phrase the question. If you need any additional information just
> ask.


Open the file for both read and write
While the file is OK
Read some bytes from the file into a buffer
Replace chars in the buffer as needed
Position the file pointer back
Write the buffer back into the file
End-while

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      04-15-2007
On Apr 15, 4:24 pm, (E-Mail Removed) wrote:
> How would this be done? For example find every "a" and replace them
> with a "b".


std::replace_copy( std::istreambuf_iterator< char >( source ),
std::istreambuf_iterator< char >(),
std:streambuf_iterator< char >( dest ),
'a',
'b' ) ;

--
James Kanze (Gabi Software) email: (E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
AnonMail2005@gmail.com
Guest
Posts: n/a
 
      04-15-2007
On Apr 15, 10:24 am, (E-Mail Removed) wrote:
> How would this be done? For example find every "a" and replace them
> with a "b".
>
> Sorry if i am not being descriptive enough, but i don't know how else
> to phrase the question. If you need any additional information just
> ask.
>
> Thanks for reading.

Depending on what system you are on, there are utilities that can
do this w/o any programming. For instance, check out the unix
utility tr.

 
Reply With Quote
 
cheesywillie@gmail.com
Guest
Posts: n/a
 
      04-16-2007
Ok thanks alot for all of the info

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression to Replace UPPER Case Text with lower case text penny Perl Misc 28 03-10-2008 01:14 AM
Replace text in text box with innerhtml type thing bobd314@gmail.com Javascript 7 08-04-2006 12:18 PM
replace text in IFRAME using innerHTML.replace(...) possible? mscir Javascript 0 10-11-2005 11:21 PM
Convert Raw Text Escaped Characters to Characters nicholas.wakefield@gmail.com Java 2 07-11-2005 09:17 PM
replace instances of text on page with image or other text? juglesh Javascript 16 12-27-2004 04:14 AM



Advertisments