Results 1 to 3 of 3

Thread: Putting something into a string...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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?

  2. #2
    New Member
    Join Date
    Jan 2001
    Posts
    1

    Cool

    You cant do it like that.

    Here is the code:

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

    hope that helps

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width