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*

7
  • 12
    cstrings aren't usually the best idea in c++ code Commented Jun 8, 2012 at 4:23
  • C string, which is a essentially a char array, must be NUL terminated. Otherwise, the functions in string.h will not function as expected. Commented Jun 8, 2012 at 4:24
  • 3
    In C, you will see this a lot. In C++, there are probably better ways to get the same thing accomplished. Commented Jun 8, 2012 at 4:24
  • 1
    So that compiler knows that the string ended. Commented Jun 8, 2012 at 4:47
  • 7
    it is not for the compiler, it is for the libraries and possibly your code. C does not support arrays properly. You can have local arrays, but there is no way to pass them about. If you try you just pass the start address (address of first element). So you can ever have the last element be special e.g. '\0' or always pass the size, being careful not to mess up. I use a set of macros to pass a start-address, length bi-tuple. Structures are another way. Classes are the best way. But C did not have classes. Commented Jun 8, 2012 at 9:55