xxxxxxxxxx
String string = "ABCDEF" ;
char[] charsFromString = string.toCharArray(); // { 'A', 'B', 'C', 'D', 'E', 'F' }
xxxxxxxxxx
// getting single character from string..
String str="abcd";
char c=str.toChar(0);
System.out.println("output is "+c); // output is a
xxxxxxxxxx
string temp = "cat";
char * tab2 = new char [temp.length()+1];
strcpy (tab2, temp.c_str());
xxxxxxxxxx
String mystr = "abcde";
void setup() {
myfunction(mystr.c_str());
}
void myfunction(char* buff) {
function stuff ..
}
xxxxxxxxxx
// CPP program for the above approach
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
// Driver Code
int main()
{
char* char_arr;
string str_obj("GeeksForGeeks");
char_arr = &str_obj[0];
cout << char_arr;
return 0;
}