'C curses cant go right [closed]

Hello i just tested curses.h on C, and i want a '#', that you can move.

if i want to get right, and down it goes but when i try to go up and left it cant.

while(ch = wgetch(win))
    {
        switch(ch)
        {
            case 'w':
            y--;
            werase(win);
            box(win, 0, 0);
            mvwprintw(win, y, x, "#");
            case 's': 
            y++;
            werase(win);
            box(win, 0, 0);
            mvwprintw(win, y, x, "#");
            case 'a':
            x--;
            werase(win);
            box(win, 0, 0);
            mvwprintw(win, y, x, "#");
            case 'd':
            x++;
            werase(win);
            box(win, 0, 0);
            mvwprintw(win, y, x, "#");
            default:
            break;
        }
    }


Solution 1:[1]

Your are missing a break for each case

    switch(ch)
    {
        case 'w':
           y--;
           werase(win);
           box(win, 0, 0);
           mvwprintw(win, y, x, "#");
           break;
        case 's': 
           y++;
           werase(win);
           box(win, 0, 0);
           mvwprintw(win, y, x, "#");
           break
        case 'a':
           x--;
           werase(win);
           box(win, 0, 0);
           mvwprintw(win, y, x, "#");
           break;
        case 'd':
           x++;
           werase(win);
           box(win, 0, 0);
           mvwprintw(win, y, x, "#");
           break;
        default:
           break; 
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pm100