如何在C中打印到所需的屏幕位置

如何在C中打印到所需的屏幕位置,c,C,在用C编码并将输出打印到屏幕上时,我们是否可以在不使用\t\t\t的情况下打印到屏幕上的其他位置?应该用某种坐标来指定位置 例如,printf(“你好”) 上面的打印信息将出现在我们想要的地方。它不应该使用\t\t\t 而是放在一个数字表示的位置。我建议您使用或更新课程 以下代码使用ncurses打印hello world: /* "Hello, world!", ncurses style. */ #include <stdlib.h> #include <stdio

在用C编码并将输出打印到屏幕上时,我们是否可以在不使用
\t\t\t
的情况下打印到屏幕上的其他位置?应该用某种坐标来指定位置

例如,
printf(“你好”)

上面的打印信息将出现在我们想要的地方。它不应该使用
\t\t\t

而是放在一个数字表示的位置。

我建议您使用或更新课程

以下代码使用ncurses打印hello world:

/*
  "Hello, world!", ncurses style.
*/


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>                  /*  for sleep()  */
#include <curses.h>


int main(void) {

    WINDOW * mainwin;


    /*  Initialize ncurses  */

    if ( (mainwin = initscr()) == NULL ) {
    fprintf(stderr, "Error initialising ncurses.\n");
    exit(EXIT_FAILURE);
    }


    /*  Display "Hello, world!" in the centre of the
    screen, call refresh() to show our changes, and
    sleep() for a few seconds to get the full screen effect  */

    mvaddstr(13, 33, "Hello, world!");
    refresh();
    sleep(3);


    /*  Clean up after ourselves  */

    delwin(mainwin);
    endwin();
    refresh();

    return EXIT_SUCCESS;
}
/*
“你好,世界!”,ncurses风格。
*/
#包括
#包括
#包括/*用于睡眠()*/
#包括
内部主(空){
窗口*mainwin;
/*初始化ncurses*/
如果((mainwin=initscr())==NULL){
fprintf(stderr,“初始化ncurses时出错。\n”);
退出(退出失败);
}
/*在屏幕中央显示“你好,世界!”
屏幕上,调用refresh()以显示更改,然后
睡眠()几秒钟以获得全屏效果*/
mvaddstr(13,33,“你好,世界!”);
刷新();
睡眠(3);
/*打扫干净*/
德尔温(缅因州);
endwin();
刷新();
返回退出成功;
}

我建议您使用或更新课程

以下代码使用ncurses打印hello world:

/*
  "Hello, world!", ncurses style.
*/


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>                  /*  for sleep()  */
#include <curses.h>


int main(void) {

    WINDOW * mainwin;


    /*  Initialize ncurses  */

    if ( (mainwin = initscr()) == NULL ) {
    fprintf(stderr, "Error initialising ncurses.\n");
    exit(EXIT_FAILURE);
    }


    /*  Display "Hello, world!" in the centre of the
    screen, call refresh() to show our changes, and
    sleep() for a few seconds to get the full screen effect  */

    mvaddstr(13, 33, "Hello, world!");
    refresh();
    sleep(3);


    /*  Clean up after ourselves  */

    delwin(mainwin);
    endwin();
    refresh();

    return EXIT_SUCCESS;
}
/*
“你好,世界!”,ncurses风格。
*/
#包括
#包括
#包括/*用于睡眠()*/
#包括
内部主(空){
窗口*mainwin;
/*初始化ncurses*/
如果((mainwin=initscr())==NULL){
fprintf(stderr,“初始化ncurses时出错。\n”);
退出(退出失败);
}
/*在屏幕中央显示“你好,世界!”
屏幕上,调用refresh()以显示更改,然后
睡眠()几秒钟以获得全屏效果*/
mvaddstr(13,33,“你好,世界!”);
刷新();
睡眠(3);
/*打扫干净*/
德尔温(缅因州);
endwin();
刷新();
返回退出成功;
}

您需要改写您的问题,我怀疑是否有人会理解您的意思。什么
\t\t\t
应用数据标签和输出?查看
ncurses
库您可以计算所需的空间数并首先打印这些空间。但是,如果您想将光标定位在特定的坐标上,那么这将取决于您的控制台处理事情的方式(它不是C语言,而是取决于系统的其他部分)。试试像ncurses这样的终端控制库,或者打印ANSI终端控制转义序列。你需要改写你的问题,我怀疑有人会理解你的意思。什么
\t\t\t
应用数据标签和输出?查看
ncurses
库您可以计算所需的空间数并首先打印这些空间。但是,如果您想将光标定位在特定的坐标上,那么这将取决于您的控制台处理事情的方式(它不是C语言,而是取决于系统的其他部分)。尝试使用诸如ncurses之类的终端控件库,或打印ANSI终端控件转义序列。