In C , there's no (real, distinct type of) strings . Every C " string " is an array of chars, zero terminated. Therefore, to extract a character c at index i from string your_string, just use char c = your_string [i];
Create an empty array with size as string length and initialize all of the elements of array to zero. Start traversing the string . Check if the character at the current index in the string is a comma (,). If yes then, increment the index of the array to point to the next element of array .
A way to do this is to copy the contents of the string to char array . This can be done with the help of c_str () and strcpy () function. The c_str () function is used to return a pointer to an array that contains a null terminated sequence of character representing the current value of the string .
We can simply call strcpy () function to copy the string to char array .
C++ c_str () function along with C++ String strcpy () function can be used to convert a string to char array easily. The c_str () method represents the sequence of characters in an array of string followed by a null character ('