How to convert an std::string to const char* or char* in C++?
文章推薦指數: 80 %
You can use the c_str() method of the string class to get a const char* with the string contents. example.
Home
CodingGround
Jobs
Whiteboard
Tools
Business
Teachwithus
TrendingCategories
DataStructure
Networking
RDBMS
OperatingSystem
Java
iOS
HTML
CSS
Android
Python
CProgramming
C++
C#
MongoDB
MySQL
Javascript
PHP
SelectedReading
UPSCIASExamsNotes
Developer'sBestPractices
QuestionsandAnswers
EffectiveResumeWriting
HRInterviewQuestions
ComputerGlossary
WhoisWho
Howtoconvertanstd::stringtoconstchar*orchar*inC++?
C++ServerSideProgrammingProgramming
Youcanusethec_str()methodofthestringclasstogetaconstchar*withthestringcontents. example#include
延伸文章資訊
- 1const char to string Code Example - Code Grepper
const char * s = "hello"; std::string str(s);
- 2C++ Char Array to String - Tutorial Kart
- 3convert char* to string c++ Code Example - Code Grepper
"std::string" has a method called "c_str()" that returns a "const char*" // pointer to its inner ...
- 4Convert std::string to const char* in C++ - Techie Delight
We can easily get a const char* from the std::string in constant time with the help of the string...
- 5The const keyword. - LIX-polytechnique