我通过双链表制作记事本,我制作了一个随链表一起移动的光标功能。但是当我在链表中插入字符时,光标停留在开头,即使我按如下方式递增:
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();
我正在使用代码块
答案 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)
重置为零。