GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Oct-2007, 09:01
srinivasanb4u srinivasanb4u is offline
New Member
 
Join Date: Oct 2007
Posts: 1
srinivasanb4u is on a distinguished road

Batch replace text


I have problem with batch replacing a text file

example: a file name :"first .txt" has the following text

A 1
B 2
C 3

another file "second .txt" has the following text
"r if this is your first time here, and if you wish to include example C++ code in your posts and messages, please surround your example codes"

task is where ever "a" is there it should repalce with 1 and "b" is there should replace with 2

can any body help in this
  #2  
Old 06-Oct-2007, 19:39
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 800
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: batch replace text


Yes we could 'help'. Instead starting off by working with the two files,
why not just declare the replacement 'source' characters:
char A, B, C;
A = '1';
B = '2';
C = '3';

Then fopen() the file for reading and writing,
read along char by char,
replace the target characters with source characters,
fclose() the file,
exit.

Then add the 'working with a source file'.
Where in this process do you have trouble? We start there!
Post the code if you have any started. That helps us to see your thinking on this.
Try searching the forum for previous examples. Keywords might be 'reading file' or 'fopen' etc.
Howard;
  #3  
Old 06-Oct-2007, 20:20
davis
 
Posts: n/a

Re: batch replace text


Quote:
Originally Posted by srinivasanb4u
I have problem with batch replacing a text file

example: a file name :"first .txt" has the following text

A 1
B 2
C 3

another file "second .txt" has the following text
"r if this is your first time here, and if you wish to include example C++ code in your posts and messages, please surround your example codes"

task is where ever "a" is there it should repalce with 1 and "b" is there should replace with 2

can any body help in this

Do you want to assume that 'A' and 'a' both are to be replaced with a '1'?

If so, do you expect that the input file for the substitution list is complete and includes all of the letters in the (Roman/Latin1) alphabet? Are we supposed to only replace those characters that are found in the substitution list?

Can we assume that a maximum of 26 characters are going to be substituted or shall we expect 52 (lowercase and uppercase) or 36/62 (includes 0-9)?


:davis:
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read unknown total of int data from text file to a 2-dim array in C or C++? ladyscarlet99 C Programming Language 2 09-Sep-2005 15:07
saving html text dopee MySQL / PHP Forum 1 17-Jan-2005 05:15
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:44.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.