字符数组
Posted TOTO2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了字符数组相关的知识,希望对你有一定的参考价值。
#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); }
以上是关于字符数组的主要内容,如果未能解决你的问题,请参考以下文章