Let's say "Hello World!"

来源:互联网 发布:安卓编程好用的软件 编辑:程序博客网 时间:2024/05/17 17:42

 

本程序运行结果可能因机器字节顺序(大端法、小端法)的不同而不同。

在Intel P4处理器、Windows操作系统上编译、运行结果如下: 
> g++ -o HelloWorld HelloWorld.cpp
> HelloWorld
  C++ : Hello World!
  char*: Hello World!
     int : Hello World!
   float : Hello World!
double: Hello World! 
>     


/*********************************** 
* 版权所有,禁止用于商业目的。 
* 文件:HelloWorld.cpp 
* 作者:虾零 
* 日期:2007年5月24日 
**********************************
*/
 
#include
<iostream> 
using namespace std; 
int main() 

// 1st: 
cout<<"  C++ : "<<"Hello World!"<<endl; 

// 2nd: 
char* cMsg="Hello World!"
cout
<<" char*: "<<cMsg<<endl; 

  
// 3rd: 
  unsigned int iMsg[]={1214606444186439051119197061450}
  cout
<<"  int : "<<(unsigned char*)iMsg<<endl; 
   
  
// 4th: 
  float fMsg[]={2.349296875e+5,4.9623302300401282264783126528e+28
               
4.682208687225141365427903922180e+30,0.0}

  cout
<<"float : "<<(unsigned char*)fMsg<<endl; 
   
  
// 5th: 
  double dMsg[]={5.83203948068402160064053545451e+40
               
1.51449963896582091508523065378e+243}

  cout
<<"double: "<<(unsigned char*)iMsg<<endl; 
   
  
return 0
}
 
 
 
原创粉丝点击