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.

8
  • 3
    Your code has no observable behavior. Commented Dec 9, 2011 at 16:36
  • @BenjaminLindley What do you mean by that? Commented Dec 9, 2011 at 16:36
  • @BenjaminLindley What you meant? Commented Dec 9, 2011 at 16:37
  • 1
    @Hunter: With strcpy, you are copying to the string that the pointer points at. buf is a local copy of whatever pointer was passed in at the call site. Even though it is itself local, the thing it points to is still the same thing that was pointed to by the pointer that it was copied from. And if your assumption was correct, then there is no need to make the char* a parameter. It should just be declared inside the function. Commented Dec 9, 2011 at 16:43
  • 2
    Also, it would need to be declared as const char *. Commented Dec 9, 2011 at 16:53