Answers for "string to char*"

C++
6

convert string to char c++

// "std::string" has a method called "c_str()" that returns a "const char*"
// pointer to its inner memory. You can copy that "const char*" to a variable
// using "strcpy()".

std::string str = "Hello World";
char buffer[50];

strcpy(buffer, str.c_str());

std::cout << buffer;	//Output: Hello World

//POSTED BY eferion ON STACK OVERFLOW (IN SPANISH).
Posted by: Guest on December-08-2020
4

string to char*

std::string str = "string";
const char *cstr = str.c_str();
Posted by: Guest on February-24-2021
8

java convert a string to char[]

String string =  "ABCDEF" ;
 
char[] charsFromString = string.toCharArray(); // { 'A', 'B', 'C', 'D', 'E', 'F' }
Posted by: Guest on March-20-2020
8

string to char in java

// getting single character from string..
String str="abcd";

char c=str.toChar(0); 

System.out.println("output is "+c); // output is a
Posted by: Guest on May-11-2020
0

how to convert a string to char in java

String s = "a";
char c = s.charAt("0");
Posted by: Guest on June-05-2021
-1

convert char to char*

char c;
char *pChar = &c;
Posted by: Guest on November-17-2020

Browse Popular Code Answers by Language