Changing string to char

Hey guys, I was trying to store a letter in the string array to a char array, but it showed this error error: invalid conversion from ‘const char*’ to ‘char’

This is the line in my code that shows error:
else if(board[row][col]=='0')
{
board[row][col]=(out[k].c_str()); //board is a char array whereas
out is a string array

Please suggest :)
c_str() function returns an array of chars so, you can't compare it with single char
you can use out[k].c_str()[n]
it will be n-th element of char[]
You could change board to a string array, as strings can just be 1 character long, and this would have the same functionality as a char array. This way you would have 2 string arrays, no conversion nessesary.
There's no need to use c_str at all.

Just do this:

 
board[row][col] = out[k][n];
Topic archived. No new replies allowed.