How to convert string to char* in C++

1 Answer

0 votes
#include <iostream>

int main() {
    std::string str = "c++ c java";
    
    const char *p = str.c_str();
    
    std::cout << p;
}




/*
run:
  
c++ c java
  
*/

 



answered May 27, 2023 by avibootz

Related questions

1 answer 131 views
1 answer 145 views
1 answer 306 views
5 answers 562 views
562 views asked May 10, 2021 by avibootz
3 answers 236 views
236 views asked May 9, 2021 by avibootz
1 answer 182 views
6 answers 533 views
533 views asked Aug 10, 2019 by avibootz
...