我正在通过双链表制作记事本,我制作了一个会随着链表移动的光标功能。但是,当我在链接列表中插入字符时,光标停留在开头,即使我按如下方式递增:
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(¬epad);
char c;
while (1) {
int x = 0, y = 0;
gotoxy(x, y);
c = getch();
if (c == 13) {
insertDoubly(¬epad, '\n'); // User pressed Enter
y++;
} else {
insertDoubly(¬epad, c);
system("cls");
printDoubly(¬epad);
x++;
}
}
return 0;
getch();
我正在使用代码块
最佳答案
移动
int x = 0, y = 0;
上面的while(1)
。每次调用 gotoxy
之前,您都将 x
和 y
重置为零。
关于光标不动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41147707/