首页 > 编程语言 > 详细

字符数组

时间:2017-11-27 12:30:57      阅读:228      评论:0      收藏:0      [点我收藏+]
#include <iostream>
using namespace std;


int main(){
    //C++当中字符数组赋值,‘‘单引号中不能为空 
    char talk[10]={G,o, ,p,a,l,y,e,r,!};
    for(int i=0;i<10;i++){
        cout<<talk[i];
    }
    cout<<endl;
}

技术分享图片

#include <iostream>
using namespace std;


int main(){
    //C++当中字符数组赋值,‘‘单引号中不能为空 
    char talk[5][5]={{ , ,*},
                    { ,*, , ,*},
                    {*, , , ,*},
                    { ,*, ,*},
                    { , ,*}};
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++)
            cout<<talk[i][j];
            cout<<endl;
    }
    cout<<endl;
}

技术分享图片

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


int main(){
    //C++当中字符数组赋值,‘‘单引号中不能为空 
    char str1[30]="People‘s Republic of ";
    char str2[]="China";
    cout<<strcat(str1,str2);

}

技术分享图片

字符数组

原文:http://www.cnblogs.com/aipopo/p/7903437.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!