C string (unlike the C++ string) is not a type, it's a concept. A contiguous sequence of chars up to and including the first zero is a "C string", regardless how or where it is stored - in an array, in a vector, in a C++ string, or in a string literal
the following code is it by default created as a c-string?
Bigint b;
b = "99999999999";
|
"99999999999" is a string literal, which is a static array of 12 const char (11 chars with value '9' and one char with value '\0'). The contents of this array happen to be a valid C string.
If it is instantly type converted, is it converted to a c string or a string? |
There is no "c string" type, so it can't be "converted" to that. The type of
"99999999999"
is
const char[12]
.
If your Bigint has a constructor that accepts
const char (&)[12]
, that constructor will be called and will access the array by reference.
If your Bigint has a constructor that accepts
const char*
, array-to-pointer conversion will be performed and a temporary pointer to the first character of the array will be constructed and passed to the constructor of Bigint.
If your Bigint has a constructor that accepts
std::string
or
const std::string&
, the converting constructor of std::string that takes const char* will be called and a temporary C++ string will be constructed holding a copy of your literal and that will be passed to the constructor.