Skip to main content
added 139 characters in body
Source Link
4pie0
  • 29.9k
  • 10
  • 86
  • 125

the actual data might be obtained with:

_Rep* _M_rep() const { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); } 

the actual data might be obtained with:

_Rep* _M_rep() const { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); } 
added 4627 characters in body
Source Link
4pie0
  • 29.9k
  • 10
  • 86
  • 125

This allows the string to be any length with only the overhead of one byte; the alternative of storing a count requires either a string length limit of 255 or an overhead of more than one byte.

from wikipedia

This allows the string to be any length with only the overhead of one byte; the alternative of storing a count requires either a string length limit of 255 or an overhead of more than one byte.

This allows the string to be any length with only the overhead of one byte; the alternative of storing a count requires either a string length limit of 255 or an overhead of more than one byte.

from wikipedia

added 4627 characters in body
Source Link
4pie0
  • 29.9k
  • 10
  • 86
  • 125

is an ASCII character with code 0, null terminator, null character, NUL. In C language it serves as a reserved character used to signify the end of a string. Many standard functions such as strcpy, strlen, strcmp among others rely on this. Otherwise, if there was no NUL, another way to signal end of string must have been used:


this code snippet comes from file basic_string.h which on my machine is located in usr/include/c++/4.4/bits/basic_string.h

So as you can see, the difference is significant.

is an ASCII character with code 0, null terminator, null character, NUL. In C language it serves as a reserved character used to signify the end of a string. Otherwise, if there was no NUL, another way to signal end of string must have been used:

So the difference is significant.

is an ASCII character with code 0, null terminator, null character, NUL. In C language it serves as a reserved character used to signify the end of a string. Many standard functions such as strcpy, strlen, strcmp among others rely on this. Otherwise, if there was no NUL, another way to signal end of string must have been used:


this code snippet comes from file basic_string.h which on my machine is located in usr/include/c++/4.4/bits/basic_string.h

So as you can see, the difference is significant.

added 4627 characters in body
Source Link
4pie0
  • 29.9k
  • 10
  • 86
  • 125
Loading
Source Link
4pie0
  • 29.9k
  • 10
  • 86
  • 125
Loading