0

I am setting up a chess board in c. The idea is the user to type the source square and destiny square (Ex: b2 b4), the first(source) scanf works perfectly, the second (destination) does not.

int main(void)
{
    int line_source, line_dest;
    char col_source, col_dest;

    while (1)
    {
        print_screen();
        printf("Type a source column and line: ");
        scanf("%c%d", &col_source, &line_source);
        printf("Type a destination column and line: ");
        scanf("%c%d", &col_dest, &line_dest);
        printf("%c%d\n", col_dest, line_dest);
        printf("%c%d\n",col_source, line_source);
        //move_piece(line_source, col_source, line_dest, col_dest);
    }

    return (0);
}

With the example of "b2 b4" line_dest is returning "32766" and col_dest is just a line break.

Someone can help me?

Ps. Sorry for my English, I'm a newbie!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0