免费注册 查看新帖 |

Chinaunix

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

[Linux] linux初学者的程序疑问 [复制链接]

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 10:01:44程序设计版块每日发帖之星
日期:2015-06-28 22:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-04-14 21:55 |只看该作者 |倒序浏览
在cygwin下执行如下程序:
#include <unistd.h>
#include <stdlib.h>

int main()
{
        if ((write(1,"here is some data\n",1)!=1
                write(2,"A write error has occurred on file descriptor 1\n",46);
                exit(0);
}

执行失败,报如下错误:
$ ./simple_write.c
./simple_write.c: line 4: syntax error near unexpected token `('
./simple_write.c: line 4: `int main()'

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 10:01:44程序设计版块每日发帖之星
日期:2015-06-28 22:20:00
2 [报告]
发表于 2014-04-14 21:57 |只看该作者
程序怎么会将数字变成表情了呢? 重新贴一遍
#include <unistd.h>
#include <stdlib.h>

int main()
{
        if ((write(1,"here is some data\n",1)!=1
                write(2,"A write error has occurred on file descriptor 1\n",46);
                exit(0);
}

求职 : 系统工程师等
论坛徽章:
5
技术图书徽章
日期:2014-04-19 22:01:05天蝎座
日期:2014-05-09 13:49:28双子座
日期:2014-06-16 15:08:042015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:55:28
3 [报告]
发表于 2014-04-15 08:50 |只看该作者
#include <unistd.h>
#include <stdlib.h>

int main()
{
    if ((write(1,"here is some data\n",1)!=1))
        write(2,"A write error has occurred on file descriptor 1\n",46);
    exit(0);
}
程序没错啊,可以出结果!

你检查下是否文件格式不对,或有中文字符!

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
4 [报告]
发表于 2014-04-15 11:05 |只看该作者
[b]回复 [url=forum.php?mod=redirect&goto=findpost&pid=&ptid=4135029]2#[/url] [color=Olive]maple412[/color] [/b]


    贴代码的时候用[code] [/code]括起来。

论坛徽章:
0
5 [报告]
发表于 2014-04-15 19:21 |只看该作者
..... 你这个。。。 你这个程序要编译 才能执行啊~
要用gcc编译成目标文件才能执行啊!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP