C++ HelloWorld 示例

C++ HelloWorld 示例

代码:

// helloworld.cpp
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    
    
    vector<string> msg = {
    
    "hello", "world", "c++"};
    for (auto it = msg.begin(); it != msg.end(); ++it)
    {
    
    
        cout << *it << (((it + 1) != msg.end()) ? " " : "\n") << flush;
    }
    return EXIT_SUCCESS;
}

编译命令:

$ gcc helloworld.cpp -o helloworld --std=c++11

输出:

hello world c++

猜你喜欢

转载自blog.csdn.net/u012101384/article/details/131516936