QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 786|回复: 10

linux下C编程怎么不能执行?

[复制链接]
发表于 2003-6-16 03:09:10 | 显示全部楼层 |阅读模式
#include <stdio.h>
main()
{
  printf("hello");
}
起名hello.c

用GCC hello.c 生成a.out在终端下执行./a没有反映
双击a.out图标也没有反映.不是应该出来hello字样吗?
发表于 2003-6-16 08:08:37 | 显示全部楼层
./a.out
run from command line
回复

使用道具 举报

 楼主| 发表于 2003-6-16 11:46:21 | 显示全部楼层
这样好象也不行。。
为什么双击也不行
回复

使用道具 举报

 楼主| 发表于 2003-6-16 11:58:25 | 显示全部楼层
./a.out我试了一下没出现hello字样.
而是直接出现下一条命令行
回复

使用道具 举报

发表于 2003-6-16 12:09:57 | 显示全部楼层
What command line? Any messages? How did you compile your codes?

$g++ -o hello hello.cpp

I don't know anything about C language, but with my C++ experiences, C++ programmer definately should put int in front of main() (Some books say put "void", but my text book and my teacher told me that I should only put "int").
回复

使用道具 举报

 楼主| 发表于 2003-6-16 12:19:30 | 显示全部楼层
red9.0 GNONE系统工具里的终端用的GCC
回复

使用道具 举报

发表于 2003-6-16 12:26:09 | 显示全部楼层
I know you used GCC, but how did you use it? Such as:

g++ -o hello hello.cpp

????
回复

使用道具 举报

 楼主| 发表于 2003-6-16 12:42:17 | 显示全部楼层
gcc hello.c
谢谢
我知道怎么了
printf("hello\n"); 加了一个\n就能显示了
回复

使用道具 举报

发表于 2003-6-16 12:45:29 | 显示全部楼层
That is not the reason. What else did you do? "\n" only make cursor change to next line.
回复

使用道具 举报

发表于 2003-6-16 13:12:46 | 显示全部楼层
"\n" only make cursor change to next line.

我觉得也是这样!
回复

使用道具 举报

发表于 2003-6-20 10:18:15 | 显示全部楼层
[quote:68a230a78d="CNOOC"]That is not the reason. What else did you do? "\n" only make cursor change to next line.[/quote]

"\n" isn't only meke cursor change to next line, the important thing is to flush the buff. This is reson when you add "\n", the hello displayed after running the program.
Ane if don't add the "\n", when you enter return, the hello will also be showed.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-15 16:32 , Processed in 0.094567 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表