0x00 and char arrays
Why do char arrays stop right before a 0x00 byte is detected and how can this problem be avoided (perhaps by using another datatype (which one and why) or a "trick" with char)?

For example in the following code, the output is "a" only, the other bytes are not displayed:

    unsigned char cbuffer[]={0x61,0x00,0x62,0x63,0x0};
	std::string sbuffer=reinterpret_cast<const char*>(cbuffer);

	cout << sbuffer << endl;
Similarly in the following code, the output is "ab":

    unsigned char cbuffer[]={0x61,0x62,0x00,0x63,0x0};
	std::string sbuffer=reinterpret_cast<const char*>(cbuffer);


Straightforward and effective workarounds to the problem (where 0x00 is kept in the array as a normal byte) would be appreciated.


0x00 and char arrays
===

Why do char arrays stop right before a 0x00 byte is detected and how can this problem be avoided (perhaps by using another datatype (which one and why) or a "trick" with char)?

For example in the following code, the output is "a" only, the other bytes are not displayed:

    unsigned char cbuffer[]={0x61,0x00,0x62,0x63,0x0};
	std::string sbuffer=reinterpret_cast<const char*>(cbuffer);

	cout << sbuffer << endl;
Similarly in the following code, the output is "ab":

    unsigned char cbuffer[]={0x61,0x62,0x00,0x63,0x0};
	std::string sbuffer=reinterpret_cast<const char*>(cbuffer);


Straightforward and effective workarounds to the problem (where 0x00 is kept in the array as a normal byte) would be appreciated.

