码迷,mamicode.com
首页 > 编程语言 > 详细

字符数组

时间:2017-11-27 12:45:13      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:char   cout   http   alt   img   c++   main   namespace   分享图片   

#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);

}

技术分享图片

字符数组

标签:char   cout   http   alt   img   c++   main   namespace   分享图片   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!