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 124 views
1 answer 134 views
1 answer 295 views
5 answers 550 views
550 views asked May 10, 2021 by avibootz
3 answers 226 views
226 views asked May 9, 2021 by avibootz
1 answer 176 views
6 answers 511 views
511 views asked Aug 10, 2019 by avibootz
...