PDA

Click to See Complete Forum and Search --> : Putting something into a string...


SteveCRM
Jan 23rd, 2001, 09:32 PM
when I do this:

board[x][y]="";

i get this error:

error C2440: '=' : cannot convert from 'char [1]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

How do I correctly assign somethng to a string? :confused:

PierreJ
Jan 23rd, 2001, 10:03 PM
You cant do it like that.

Here is the code:

strcpy(board[x][y], "");

hope that helps

parksie
Jan 24th, 2001, 12:22 PM
What is the definition for the board?

You can't randomly copy things into a string, as you need to allocate a buffer first, since in C, strings are only arrays of single characters. You can use the string class from the STL, but for a lot of things it's just as easy to use the C-style methods.