简体   繁体   中英

How to convert a char array to a string?

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy . However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to: string str = "This is a test .

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy . However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to: string str = "This is a test .

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy . However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to: string str = "This is a test .

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy . However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to: string str = "This is a test .

Converting a C++ string to a char array is pretty straightorward using the c_str function of string and then doing strcpy . However, how to do the opposite?

I have a char array like: char arr[ ] = "This is a test"; to be converted back to: string str = "This is a test .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM