What is a C-string?

Pages: 12
Multibyte sttrings are in any case are arrays.:)
For example in the C standard there is written

For wide string literals prefixed by the letter L, the array elements have type wchar_t and are initialized with the sequence of wide characters corresponding to the multibyte character sequence, as defined by the mbstowcs function with an implementationdefined current locale

Or let read the description of the function itself

The mbstowcs function converts a sequence of multibyte characters that begins in the initial shift state from the array pointed to by s into a sequence of corresponding wide characters and stores not more than n wide characters into the array pointed to by pwcs. No multibyte characters that follow a null character (which is converted into a null wide character) will be examined or converted.

Strings are objects and as any object they have types that defined as arrays containing the terminating zero. So if you deal with strings then "No characters that "...follow a null character ... will be examined"

From this phrase it is clear enough what are strings.:) Structures are not strings.:)
Last edited on
vlad from moscow wrote:
Strings are objects and as any object they have types that defined as arrays
standard error redirected 2> /dev/null

I'm out of this.
Last edited on
C is less strict about types. The char* that you pass to the string functions doesn't really care what it is as long as it is null terminated.
There are strings and there are string literals. The difference between them is that underlaying character arrays of string literals may not be changed and have sizes that exactly equal to numbers of characters in string literals. While strings can have underlyong character arrays that have sizes much greater then numbers of characters in corresponding strings.
Topic archived. No new replies allowed.
Pages: 12