First, you'll have to tell the string constructor the size; it can only determine the size if the input is null-terminated. Something like this would work:
std::string str("1234,5678\000,ABCD,EFG#", sizeof("1234,5678\000,ABCD,EFG#")-1);
There's no particularly nice way to avoid the duplication; you could declare a local array
char c_str[] = "1234,5678\000,ABCD,EFG#"; // In C++11, perhaps 'auto const & c_str = "...";'
std::string str(c_str, sizeof(c_str)-1);
which might have a run-time cost; or you could use a macro; or you could build the string in pieces
std::string str = "1234,5678";
str += '\0';
str += ",ABCD,EFG#";
Finally, stream the string itself (for which the size is known) rather than extracting a c-string pointer (for which the size will be determined by looking for a null terminator):
std::cout << "length" << str;
UPDATE: as pointed out in the comments, C++14 adds a suffix for basic_string literals:
std::string str = "1234,5678\000,ABCD,EFG#"s;
^
which, by my reading of the draft standard, should work even if there is an embedded null character.
c_str()member function of the standard C++ string class. What does it look like?