Re: embedded questions!!!



Rufus V. Smith wrote:
"#define" <u4karsh@xxxxxxxxx> wrote in message

Some C questions were bugging me from quite some time. Any answers! please share.

2.  Given 2 Strings char *str1 = "JHONSON";
                           char *str2 = "O";

what is the fastest way to remove all occurences of letter O
from str1.

str1[0] = '\0';

Bzzt - WRONG. str1 contains a pointer to a non-modifiable string (which may well reside in ROM). str1 itself contains no letter O. Thus the only way is:


  str1 = "JHNSN";

Things would be different if the original declaration was:

    char str1[] = "JHONSON";

which would have initialized a character array to a C string.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on
 "show options" at the top of the article, then click on the
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
.



Relevant Pages

  • Re: embedded questions!!!
    ... string (which may well reside in ROM). ... str1 itself contains no ... the broken "Reply" link at the bottom of the article. ...
    (comp.arch.embedded)
  • Re: embedded questions!!!
    ... what is the fastest way to remove all occurences of letter O ... from str1. ... may well reside in ROM). ...
    (comp.arch.embedded)
  • Re: embedded questions!!!
    ... str1 itself contains no ... this type of thing can be very compiler dependent! ... that will store the string in ROM. ...
    (comp.arch.embedded)