Re: Replace word in text file

From: Ed Morton (mortonAVOIDINGSPAM_at_lucent.com)
Date: 11/05/03


Date: Wed, 05 Nov 2003 15:24:20 -0600


On 11/5/2003 3:14 PM, William Payne wrote:
> "Richard Heathfield" <dontmail@address.co.uk.invalid> wrote in message
> news:bobood$62v$2@titan.btinternet.com...
<snip>
>>I suggest you replace this line with:
>>
>> if(strcmp(line, "set imap_user=root\n") == 0)
<snip>
> Thanks for the quick reply, Mr Heathfield. It appears that you are right
> about fgets() not stripping the newline because I got an empty line between
> the printf()-statements in the while()-loop. So I wrote strcmp() as you
> suggested, but it still fails to match the string. =( Any ideas?

Not all OSs just use "\n" as the line terminator. Try adding "\n\r" instead of
just "\n". This approach still fails if "fgets()" doesn't read to the end of
the line...

        Ed.

> / William Payne
>
>



Relevant Pages

  • Re: C as a Platonic pathology
    ... formatting here adds linebreaks at ... and you claimed falsely that I'd added the newline. ... Usenet is not a client. ...
    (comp.lang.c)
  • Re: C as a Platonic pathology
    ... I claimed truly that the code you posted had the newline there. ... Keith Thompson has pointed out that it may have been the server that ... Usenet is not a client. ...
    (comp.lang.c)
  • Re: strong name exception on SecurityAction.Demand, works fine for LinkDemand
    ... - in fact the behaviour has changed in 2.0 that fully trusted code always passes SNIP demands. ... so the page class derives from the code behind class to call into a SNIP demand - the stack walk fails when the page class is reached. ... I noticed that calling the component fails when the SecurityAction.Demand is on, while it succeeds when SecurityAction.LinkDemand is on. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: some tricky questions
    ... Unless the actual standard differs from n1124.pdf, ... binary file and reading it back in by at least the same program must ... just always fails -- which is conforming, but not in the spirit of the ...
    (comp.lang.c)
  • Re: get obsolute path with file
    ... What if "cd" fails? ... complex solutions to cover more contingencies; ... in most cases that is, as you named it, just overengineering. ...
    (comp.unix.shell)