Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ncurses.h,wprintw不';即使在刷新后也无法工作_C_Window_Ncurses - Fatal编程技术网

ncurses.h,wprintw不';即使在刷新后也无法工作

ncurses.h,wprintw不';即使在刷新后也无法工作,c,window,ncurses,C,Window,Ncurses,我正在使用库ncurses,当我尝试调用wprintw(),然后在右侧窗口上执行wrefresh时,它不会打印任何内容 #include <stdio.h> #include <stdlib.h> #include <ncurses.h> int main() { WINDOW *winTest; //The window int rows, cols; //Rows and colums in the terminal inits

我正在使用库ncurses,当我尝试调用
wprintw()
,然后在右侧窗口上执行
wrefresh
时,它不会打印任何内容

#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>

int main()
{
    WINDOW *winTest; //The window
    int rows, cols; //Rows and colums in the terminal

    initscr(); //Starting NCurses
    raw(); //Calling 'getch()' doesn't wait for '\n' 
    noecho(); //Doesn't print what's written by user
    curs_set(0); //Doesn't display the cursor

    getmaxyx(stdscr, rows, cols); //How many rows and colums in stdscr (the terminal)

    winTest = newwin(10, 10, rows/2, cols/2); //Creates a square WINDOW at the center of the terminal

    mvwprintw(winTest, 0, 0, "Test"); //Prints "Test" on the created window

    wrefresh(winTest); //Refreshes so what's done is displayed
    getch(); //Pause

    delwin(winTest); //Free the memory for winTest
    endwin(); //Ends NCurses
    return 0;
}
我在gnome终端中执行。

如前所述,您应该替换:

getch();
作者:

我将第二个暂停getch()替换为我自己的暂停函数:scanf(“%*s”);然后在中间显示测试结果。我认为发生的事情是,它一次经历了两次暂停,因此您从未看到“测试”,因为它被删除的速度与创建的速度一样快托尼·鲁斯

感谢托尼·鲁斯,他回答了我的问题。即使我仍然不明白为什么
getch()
会删除所写内容,用
scanf(“%*s”)替换它也行

PS:不知道如何判断这个问题已经解决:/


编辑:您也可以在任何窗口上调用“wgetch(aWindow)”,每个窗口都将正确显示:)(感谢Ruud告诉它)

看到您隐藏所有编译器错误不是一个好迹象。删除这些内容:
-Wall-Werror-Wpedantic-Wextra-Wformat
编译器可能会告诉您一些重要的信息。@TonyRuth:您知道这些标志启用了附加警告(并且使它们致命)?@TonyRuth ehem。。。这是启用所有编译器错误,而不是隐藏它们。啊,你是对的,对不起。可能是
getch();
wgetch(winTest);