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 130 views
1 answer 144 views
1 answer 305 views
5 answers 561 views
561 views asked May 10, 2021 by avibootz
3 answers 235 views
235 views asked May 9, 2021 by avibootz
1 answer 181 views
6 answers 532 views
532 views asked Aug 10, 2019 by avibootz
...