免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2188 | 回复: 3
打印 上一主题 下一主题

[C] newt编写文本模式可视化程序请教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-17 19:03 |只看该作者 |倒序浏览
使用newt写了如下所示的一个简单的程序,编译出错,提示'NULL' undeclared 。但假如我把NULL用0替换,编译也会出错,提示
“undefined reference to `newtInit'”这样的信息。请教各位,该怎么写才不会出错呢?谢谢。

$ cat -n  helloworld.c                    
     1  #include<newt.h>
     2
     3  int main(int argc, char *argv[])
     4  {
     5      newtComponent form, button;
     6      newtInit();
     7      newtCls();
     8      newtPushHelpLine("Press button to exit...");
     9      newtOpenWindow(10, 5, 40, 6, "Button Sample");
    10      button = newtButton(10, 1, "HelloWorld!");
    11      form = newtForm(NULL, NULL, 0);
    12      newtFormAddComponents(form, button, NULL);
    13      newtRunForm(form);
    14      newtFormDestroy(form);
    15      newtFinished();
    16  }
$ gcc -g helloworld.c -o helloworld
helloworld.c: In function 'main':
helloworld.c:11: error: 'NULL' undeclared (first use in this function)
helloworld.c:11: error: (Each undeclared identifier is reported only once
helloworld.c:11: error: for each function it appears in.)
$

论坛徽章:
0
2 [报告]
发表于 2008-11-17 20:55 |只看该作者
搞定了
使用“gcc -g helloworld.c -o helloworld -lnewt”编译通过。

论坛徽章:
0
3 [报告]
发表于 2008-11-17 23:03 |只看该作者

回复 #2 flyhighxu 的帖子

如果玩newt,可以参考下linux安装里的文本安装对应的代码,写的很不错。

在anaconda里有,是c代码。

论坛徽章:
0
4 [报告]
发表于 2008-11-18 11:18 |只看该作者
(void*)0应该也是可以的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP