如何在gcc中实现gotoxy() [英] How could I achieve gotoxy() in gcc
问题描述
我在 ubuntu 中使用 gcc .so,我在终端中编译并执行。但在在线编程竞赛中,他们需要输出,如图所示。
为此,如果我使用 TURBOC ,我可以使用 conio.h 使用 gotoxy()取得螺旋格式输出。 但在Ubuntu中,我如何实现这一点?
使用ncurses库。 >
以下是一个范例,根据 http ://www.paulgriffiths.net/program/c/srcs/curhellosrc.html
#include< stdlib.h>
#include< stdio.h>
#include< curses.h>
int main(void){
WINDOW * mainwin;
/ *初始化ncurses * /
if((mainwin = initscr())== NULL){
fprintf(stderr,Error initialising ncurses.\\ \\ n);
exit(EXIT_FAILURE);
}
move(10,15);
addch('X');
refresh();
getch();
delwin(mainwin);
endwin();
refresh();
return EXIT_SUCCESS;
}
更多信息请点击这里: http://invisible-island.net/ncurses/ncurses-intro.html#stdscr
I am using gcc in ubuntu.so, I compile and execute in terminal. But In a online programming contest, they require the output as shown in diagram.
For that, if I use TURBOC I can get it using conio.h using gotoxy() to get spiral format of output. But in Ubuntu , How could I achieve this?
Use the ncurses library.
Here's an example, adapted from http://www.paulgriffiths.net/program/c/srcs/curhellosrc.html
#include <stdlib.h>
#include <stdio.h>
#include <curses.h>
int main(void) {
WINDOW * mainwin;
/* Initialize ncurses */
if ( (mainwin = initscr()) == NULL ) {
fprintf(stderr, "Error initialising ncurses.\n");
exit(EXIT_FAILURE);
}
move(10, 15);
addch('X');
refresh();
getch();
delwin(mainwin);
endwin();
refresh();
return EXIT_SUCCESS;
}
Further information is available here: http://invisible-island.net/ncurses/ncurses-intro.html#stdscr
这篇关于如何在gcc中实现gotoxy()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!