c++中char *与char[]区别

来源:互联网 发布:哥特式lolita淘宝 编辑:程序博客网 时间:2024/06/06 01:45
// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <string>#include <iostream>using namespace std;int _tmain(int argc, _TCHAR* argv[]){    char *c1 = "abc";    char c2[] = "abc";    cout <<" *c1是 :" << *c1 <<endl;    cout <<"c2 是:"<< c2 << endl;    cout <<"*c2 是:"<< *c2 << endl;    string namee = "xuhaitao";    const char *c3 = namee.data();    cout <<"*c3是: "<< *c3 << endl;    const char *c4 = namee.c_str();    cout <<"*c4是: "<<*c4 << endl;    getchar();    return 0;}


上面代码,控制台打印结果:

这里写图片描述



FR:海涛高软(hunk Xu) QQ技术交流群:386476712