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”这个方式是引用某个目录下的文件,需要用户自己放到目录里面,通常当前目录。
3万+

被折叠的 条评论
为什么被折叠?



