Hi i have the following code:
char msg[10000];
string mystr = "hello";
// stores mystr into msg
copy(mystr.begin(), mystr.end(), msg);
After the code copies, i want to clear the contents of char msg[10000]. How do i do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using modern facilities
Not sure why you wanna copy it first and then clear it, but that’s how you can do it. Without C++11 generalized initializers, you can say
Of course, you can always use
boost::arrayinsteadstd::array, it works the same.