1// "std::string" has a method called "c_str()" that returns a "const char*"
2// pointer to its inner memory. You can copy that "const char*" to a variable
3// using "strcpy()".
4
5std::string str = "Hello World";
6char buffer[50];
7
8strcpy(buffer, str.c_str());
9
10std::cout << buffer; //Output: Hello World
11
12//POSTED BY eferion ON STACK OVERFLOW (IN SPANISH).
13
1String string = "ABCDEF" ;
2
3char[] charsFromString = string.toCharArray(); // { 'A', 'B', 'C', 'D', 'E', 'F' }
1// getting single character from string..
2String str="abcd";
3
4char c=str.toChar(0);
5
6System.out.println("output is "+c); // output is a