I can't for the love of god understand why scanf doesnt work.
here's the code:
Code:void main () { char prev_move[3], next_move[2], new_move; printf("Press 'y' for a new move or anything else to exit: "); scanf(" %c",&new_move); while(new_move == 'y') { printf("\nchoose the pawn you want to move and it's current position: "); scanf(" %s",&prev_move); printf("\nchoose next move: "); scanf(" %s",&next_move); for(int i=0; i<3; i++) printf("%c",prev_move[i]); } }
prev_move is a 3 positions char array. for prints 3 chars of which the first is a whitespace, and the the other two that I have entered from the keyboard. Scanf seems to place a whitespace in prev_move[0]. Why is this happening?