C++语言实现hello world代码

代码和注释

两种注释方式:

  • 一种是以/*开始、以*/结束的块注释(block comment);
  • 另一种是以//开始、以换行符结束的单行注释(line comment)。

 

以下用了几种方法来输出hello world


/* #include<iostream>
    #:预处理标志,后面跟预处理指令,include:预处理指令,包含 <iostream>:c++头文件,输入输出流
        这行的作用就是在预编译之前先执行这行代码。系统提供的头文件用<>括起来
   #include<iostream.h>
        这个头文件是c标准的头文件,c++中叫非标准库文件。
   using namespace std;使用标准命名空间。也就是说C++当中的标准库文件,函数,对象啊等都存放在std空间中,
        作用:作用是在编写大程序的时候能够定义重复的变量,(标识符)
        当需要调用标准空间中的对象,函数的时候调用方法:std::cout std::cin std::endl;需要加双冒号
    #include<iostream> #include<iostream.h>的区别:
        使用#include<iostream>的时候,需要使用using namespace std;而#include<iostream.h>不需要
*/
#include <iostream>
//using std::cout;  //使用std空间中cout对象。::调用的意思
//using std::endl;
int main(void)
{
    //cout<<"hello world"<<endl;
    std::cout<<"hello world"<<std::endl;
    return 0;
}
 
/*
#include<iostream>
using namespace std;
int main(void)
{
    cout<<"hello world"<<endl;
    return 0;
}
 
 
#include<iostream.h>
  int main(void)
  {
    cout<<"hello world"<<endl;
    return 0;
  }
*/

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值