Join 306,749 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,900 people online right now. Registration is fast and FREE... Join Now!
Why not use string::copy() and string::length()?
string str = "ABCDEFG";
size_t len = str.length();
char* buf = new char[len]
str.copy(buf, len);
buf[len]='\0';
Jw