LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 843|回复: 7

问一个关于hello c的问题

[复制链接]
发表于 2004-1-8 13:47:29 | 显示全部楼层 |阅读模式
我编了个hello c的程序如下:


         # include<iostream.h>
         main()
             {
                cout<<"hello,c\n";
              }

    在djgpp(dos下的gcc)编译出错,担示大概是说iostream是16位的文件头之类的,请问各位老大在linux可以编译成功吗?我用的机子是公家的,没有安linux.
发表于 2004-1-8 13:50:58 | 显示全部楼层
你这个c是那个c?是什么平台下的。。。。
 楼主| 发表于 2004-1-8 13:54:04 | 显示全部楼层
dos平台下的32位 gcc编译器
发表于 2004-1-8 14:00:44 | 显示全部楼层
没用过dos下的gcc。。。
发表于 2004-1-8 15:11:55 | 显示全部楼层
#include <iostream>

明明是c++...
 楼主| 发表于 2004-1-8 15:15:18 | 显示全部楼层
是C++啊,用gpp -o hello hello.cpp命令编译的。我只是好奇在linux下这个程序应该怎么写才对
发表于 2004-1-8 21:49:18 | 显示全部楼层

  1. # include <iostream>
  2. using namespace std;
  3. int main(void)
  4. {
  5.    cout<<"hello."<<'\n';
  6.    return 0;
  7. }
复制代码


在linux下,这样一定没错,标准的C++。
 楼主| 发表于 2004-1-9 23:04:58 | 显示全部楼层
谢谢斑主!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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