C++入门经典-例6.23-字符串数组赋值与string

1:代码如下:

// 6.23.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main(int argc, _TCHAR* argv[])
{
    char aArray[8] ="Welcome";
    string s = aArray;
    cout<<s<<endl;
    s = &aArray[2];
    cout<<s<<endl;
    return 0;
}
View Code

运行结果:

原文地址:https://www.cnblogs.com/lovemi93/p/7543506.html