Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Can you show your call to this function? Commented Mar 12, 2012 at 10:34
  • removeDuplicate("heee"); Commented Mar 12, 2012 at 10:37
  • yes that was the problem with call...heee doesnot have \0 :P..Is it the problem? Commented Mar 12, 2012 at 10:39
  • 1
    Actually, it does have \0 "heee" is just like {'h', 'e', 'e', 'e', '\0'} Commented Mar 12, 2012 at 10:44
  • Your code contains (at least) two dangerous styles, which probably cause this function to behave different than you have in mind: Dont use a variable and ++ it in the same expression: str[j] = str[++j];. The C specification doesn't specify how the compiler should behave in this case (see c-faq.com/expr/evalorder1.html). Also doing i-- is not a very wise thing to do in such constructions. In this case i will become negative in a lot of cases, and str[-1] is clearly not valid here. Commented Mar 12, 2012 at 10:52