光标没有移动

时间:2016-12-14 16:38:42

标签: c

我通过双链表制作记事本,我制作了一个随链表一起移动的光标功能。但是当我在链表中​​插入字符时,光标停留在开头,即使我按如下方式递增:

void gotoxy(int x, int y) {
   COORD coord;
   coord.X = x; coord.Y = y;
   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

int main() {
struct DLLADT notepad;
init(&notepad);
char c; 

while (1) {
    int x = 0, y = 0;
    gotoxy(x, y);
    c = getch();

    if (c == 13) {
        insertDoubly(&notepad, '\n'); // User pressed Enter
        y++;
    } else {
        insertDoubly(&notepad, c);
        system("cls");
        printDoubly(&notepad);
        x++;
    }
}

return 0;
getch();

我正在使用代码块

1 个答案:

答案 0 :(得分:1)

移动

composer require behat/transliterator

以上Mark directory as -> Unmark as sources root。您每次拨打public class YourClass{ private static final YourClass INSTANCE = new YourClass(); private YourClass{Your code..} //This is the factorie public static YourClass getInstance(){return INSTANCE;} } 之前都要将int x = 0, y = 0; while(1)重置为零。