我怎么能实现海合会gotoxy() [英] How could I achieve gotoxy() in gcc

查看:265
本文介绍了我怎么能实现海合会gotoxy()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 GCC 的Ubuntu 。所以,我编译和执行中的终端。但在在线编程竞赛,他们需要的输出,如图图。

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.

有关,如果我使用 TURBOC 我可以用得到它的 CONIO.H 使用的 gotoxy()以获得螺线格式的输出。 但是在Ubuntu中,我怎么能做到这一点?

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?

推荐答案

使用ncurses库。

Use the ncurses library.

下面是一个例子,改编自 http://www.paulgriffiths.net/程序/ C /索马里红新月会/ curhellosrc.html

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;
}

更多信息,请访问: http://invisible-island.net/ ncurses的/ ncurses的intro.html# stdscr上

这篇关于我怎么能实现海合会gotoxy()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆