VC++ 入门程序

代码

#include<iostream>

using namespace std;

int main(){

    cout<<"hello world" << endl;
    system("pause");
}

解释

  • #include<iostream>:引入头文件,然后才能使用 std、cout

  • using namespace std;:告诉编译器使用 std 命名空间,使用该命名空间后,才能在下面直接使用 cout、endl

  • int main():入口函数,相当于学校大门口,都从这个门口进

  • cout<<"hello world":向控制台打印 hello world

  • endl:换行,也可以是 \n

  • system("pause");:相当于在 dos下执行 pause 命令