Hello Guys,
Is it nessessary that to build string object one has to provide NULL terminated char array or just char array without NULL termination will also do..
Thanks in Advance
Regards
Prashant,
Printable View
Hello Guys,
Is it nessessary that to build string object one has to provide NULL terminated char array or just char array without NULL termination will also do..
Thanks in Advance
Regards
Prashant,
Please Ignore it..Got the answer..
For those who find this thread ...
You can do either:
Code:const char x[4] = {'a', 'b', 'c', 0};
const char y[3] = {'a', 'b', 'c'};
std::string a(&x[0]);
std::string b(&y[0], 3);
If you happen to invoke the char* argument taking constructor of std::string, then yes, it is necessary to have it null-terminated.