Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.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/1/wordpress/12.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
用诅咒在C程序中创建一个方框_C_Ncurses_Curses - Fatal编程技术网

用诅咒在C程序中创建一个方框

用诅咒在C程序中创建一个方框,c,ncurses,curses,C,Ncurses,Curses,我试图创建一个盒子,盒子里有一个游戏,但是现在我正在使用文本这是我的盒子进行测试。我第一次被诅咒弄糊涂了,但我正试图在业余时间自学。我以前对其他C程序没有任何问题,但这一次,当我在Repl.it上编译时,我不断收到错误消息,但是#include不存在于系统文件或Linux系统中 #include <stdio.h> #include <ncurses.h> #include <stdlib.h> int main(int argc, char ** argv

我试图创建一个盒子,盒子里有一个游戏,但是现在我正在使用文本
这是我的盒子
进行测试。我第一次被诅咒弄糊涂了,但我正试图在业余时间自学。我以前对其他C程序没有任何问题,但这一次,当我在Repl.it上编译时,我不断收到错误消息,但是
#include
不存在于系统文件或Linux系统中

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

int main(int argc, char ** argv){

  initscr();
  int height, width, start_y, start_x;
  height = 10;
  width = 20;
  start_y = start_x = 10;

  WINDOW * win = newwin(height, width, start_y, start_x);
  refresh();

  box(win, 0, 0);
  mvwprintw(win, 1, 1, "this is my box");
  wrefresh(win);

  int c = getch();

  endwin();



return 0;
}
汇编时使用:

g++ -Incurses project.c -o project

您必须将链接器标志传递给编译器,以便在编译时链接
ncurses
库。此标志为
-lncurses

根据OP的评论,编译器调用为:

g++ -Incurses project.c -o project
在链接器标志中,初始的
l
(ell)被错误地设置为
I
(很容易出错)。此外,链接器标志在此调用中的位置错误。链接器标志必须在其源文件之后。更好的调用是:

g++ -o project project.c -lncurses
我不知道OP为什么在这里使用
g++
来编写C代码;最好直接使用
gcc
。另外,我建议始终启用一些警告:

gcc -std=c11 -Wall -Wextra -Wpedantic -o project project.c -lncurses

您必须将链接器标志传递给编译器,以便在编译时链接
ncurses
库。此标志为
-lncurses

根据OP的评论,编译器调用为:

g++ -Incurses project.c -o project
在链接器标志中,初始的
l
(ell)被错误地设置为
I
(很容易出错)。此外,链接器标志在此调用中的位置错误。链接器标志必须在其源文件之后。更好的调用是:

g++ -o project project.c -lncurses
我不知道OP为什么在这里使用
g++
来编写C代码;最好直接使用
gcc
。另外,我建议始终启用一些警告:

gcc -std=c11 -Wall -Wextra -Wpedantic -o project project.c -lncurses

编译时是否将
ncurses
链接到
-lncurses
标志?我使用了
g++-incireses project.c-o project
这应该是小写的“ell”,而不是大写的“I”,链接器标志需要跟在源文件后面:
g++-o project.c-lncurses
。马上!我希望我能投你一票作为答案。谢谢,不客气;我已将我的评论转换为答案。编译时是否将
ncurses
-lncurses
标志链接?我使用了
g++-引发项目。c-o项目
应该是小写的“ell”,而不是大写的“I”,链接器标志需要跟在源文件后面:
g++-o project.c-lncurses
。马上!我希望我能投你一票作为答案。谢谢,不客气;我已经把我的评论转换成答案。代码示例是ISOC——根本不需要C++。代码示例是ISOC——根本不需要C++。