Null-terminated string: Difference between revisions

Content deleted Content added
Ktracy (talk | contribs)
mNo edit summary
Ktracy (talk | contribs)
mNo edit summary
Line 10:
== C String header ==
 
The <cstring> header and its functions are the ideal way to work with C strings. Typical operator use with C strings will frequently create problems with pointers. As an example, using the = operator between two C strings does not copy the values in the array but copies a pointer to thisthe array. This is incorrect usage for most typical applications.
 
 
Line 16:
 
To copy a C string correctly, the following format could be used
 
 
<code>memcpy(CstringDst, CstringSrc, strlen(CstringSrc) + 1);</code>
 
 
Where CstringDst is the destination C string to be copied into and CstringSrc is the source of the C string. The last argument will set the length of the destination C array. It will set this length to the length of the source plus 1 to account for the terminating character.
Line 23 ⟶ 25:
 
The functions included in <cstring> are as follows:
 
 
'''Copying:'''