菜鸟学习c、c++

1、输出hello world
使用mingw编辑器。
helloAtom.cpp

//#include <stdio.h>
  // #include <iostream>  
 //using namespace std;  
    int main()  
    {  
   // cout<<"hello 123atom111"<<endl;  
    puts("123");
    }  

错误

C:\log>g++ helloAtom.cpp
helloAtom.cpp: In function 'int main()':
helloAtom.cpp:7:12: error: 'puts' was not declared in this scope
  puts("123");

看出必须 添加#include

//#include <stdio.h>
  // #include <iostream>  
 //using namespace std;  
    int main()  
    {  
   cout<<"hello 123atom111"<<endl;  
    //puts("123");
    }  
C:\log>g++ helloAtom.cpp
helloAtom.cpp: In function 'int main()':
helloAtom.cpp:6:4: error: 'cout' was not declared in this scope
    cout<<"hello 123atom111"<<endl;
    ^
helloAtom.cpp:6:30: error: 'endl' was not declared in this scope
    cout<<"hello 123atom111"<<endl;
                              ^

这个错误需要添加

//#include <stdio.h>
#include <iostream>  
 using namespace std;  
    int main()  
    {  
   cout<<"hello 123atom111"<<endl;  
    //puts("123");
    }  

pass。

命令
puts—
#include <stdio.h>
cout—
#include <iostream>
using namespace std;

include 这种方式是引用资源库中的文件
include “XXX”这个方式是引用某个目录下的文件,需要用户自己放到目录里面,通常当前目录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值