正文

第一个linux下的C程序2007-11-08 09:47:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/daweizhao/30811.html

分享到:

又有了一个第一次,linux下的C程序: 1 //file HelloWorld.cpp    2 #include <stdio.h>    3 int main(int argc, char **argv)    4 {    5     printf("hello linux world\n");    6 } 编译命令:g++ -o helloworld helloworld.cpp 运行命令:./helloworld 结果:hello linux world 自己要注意的问题: 1 是<stdio.h> 还有另外一种写法:     1 //file HelloWorld.cpp    2 #include <stdio.h>    3 #include <iostream.h>    4     5 int main()    6 {    7 //  printf("hello linux world\n");    8  cout<<"hello world linux\n"<<endl;    9 //cout.operator<<("Hello,World!").operator<<(endl);   10  return 0;   11 } 1 注意cout的输出语句为:cout<<"hello world linux\n"<<endl;不知道网上为何有的人把后面的<<endl去掉。没有放全么? 2 在按照网上原码编译时出现了如下问题:`cout' undeclared (first use this function)。在网上查知道没有引入#include <iostream.h> 3 第9行相当于是理解cout的运行原理,放在下面:cout是一个iostream类的对象,它有一个成员运算符函数operator<<,每次调用的时候就会向输出设备(一般就是屏幕啦)输出东东。出处:http://tech.163.com/05/1123/11/2388N2D40009159Q.html

阅读(2747) | 评论(2)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册