X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: info AT hoekstra-uitgeverij DOT nl (Richard Bos) Newsgroups: comp.lang.c,comp.os.msdos.djgpp,comp.lang.c++ Subject: Re: String substitution to another Date: Mon, 03 Dec 2001 14:57:29 GMT Organization: Go wash your mouth. Lines: 29 Message-ID: <3c0b7185.576922605@news.worldonline.nl> References: <3C0BEC9D DOT 4D74A6CA AT surfeu DOT fi> NNTP-Posting-Host: vp228-78.worldonline.nl X-Trace: nereid.worldonline.nl 1007391470 29356 195.241.228.78 (3 Dec 2001 14:57:50 GMT) X-Complaints-To: newsmaster AT worldonline DOT nl NNTP-Posting-Date: 3 Dec 2001 14:57:50 GMT X-Newsreader: Forte Free Agent 1.21/32.243 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Mr. Veli Suorsa" 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. . 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. 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: . Richard