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.

Required fields*

8
  • 7
    char bar[12]; strcpy(bar, FOO);? Commented Jan 30, 2020 at 12:08
  • 1
    Do you need to modify the string at all? If not, why not just stay with the pointer? Commented Jan 30, 2020 at 12:08
  • @Aconcagua: yes the string must be modified later. Commented Jan 30, 2020 at 12:09
  • @mch and Thomas Sablik: your solutions would work, but if possible I'd like a one-line solution. Commented Jan 30, 2020 at 12:10
  • I would add Assert(sizeof bar > strlen(FOO)); to the test code. And thereafter strcpy(bar, FOO);. This makes your tester more robust agains changes in the generated code. Commented Jan 30, 2020 at 12:15