delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/10/05:02:51

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Mr. Veli Suorsa" <veli DOT suorsa AT surfeu DOT fi>
Newsgroups: comp.lang.c,comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: String substitution to another
Date: Mon, 10 Dec 2001 11:46:48 -0800
Organization: Oulu
Lines: 62
Message-ID: <3C151123.D1E94FE8@surfeu.fi>
NNTP-Posting-Host: otogate2.otol.fi
Mime-Version: 1.0
X-Trace: pan.oamk.fi 1007977711 29516 193.167.101.89 (10 Dec 2001 09:48:31 GMT)
X-Complaints-To: usenet AT pan DOT oamk DOT fi
NNTP-Posting-Date: Mon, 10 Dec 2001 09:48:31 +0000 (UTC)
X-Mailer: Mozilla 4.08 [en] (Win16; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Tanks for Your replies; Richard, Aaron, osmium and Fred!

>"Mr. Veli Suorsa" <veli DOT suorsa AT surfeu DOT fi> wrote:
>
>> Please, show me, how I can read text file and substitute one string
to
>> another (e.g. 'christmas card' -> 'money') and save file again to
same
>> name.
>
><http://www.eskimo.com/~scs/C-faq/q12.30.html>.
>
>In short, your best bet is probably to re-write the entire file. Read a

>line from one file, substitute text as necessary, rewrite line to new
>file, repeat ad lib.

I will try this way; read and then ad to new file.

Have You any big 'christmas card' -> 'money'- converter ready somewhere?

December is the right time to do this substitution example, because
every place are full of these christmas cards.

>Note also that this:
>
>>       gets( filename );
>
>is an evil function, which you shouldn't use under any circumstances
>excepting physical duress above the "agony" level, and that this:
>
>>    while ( !feof( fileptr ) )
>>    {
>>       fgets( strline, MAXLINELEN, fileptr );
>
>>    }
>
>is not the best way to read a file, because:
><http://www.eskimo.com/~scs/C-faq/q12.2.html>.

Don't worry about "evil functions", Richard, code seems to work very
well.
No warnings, no errors in my test compiler as usual ;-)

I read these eskimo sites ("eskimo" name is an icecream stick here in
coldy and snowy Finland) and everyhing seems to be Okey.

With Best Regards


Veli Suorsa
---
"People must believe to the future to be able to live!"
********************************** J.V.Snellman, 1890.

Oulu, FINLAND
***   Suorsa Team Homepage   ***
http://SuorsaTeam.TopCities.Com/
Mailto:VSuorsa AT Surfeu DOT Fi


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019