字符串定义:
char buffer[128];
char buffer[128] = "hello world"; // sizeof() 函数 取得定义 长度 128,字符串有效长度 11
char buffer[] = "hello world"; // sizeof() 函数取得定义的 长度 12,字符串有效长度 11
字符串赋值 strcpy()
char buffer[128];
char str1[128]="hello world";
strcpy(buffer,"hello world");
strcpy(buffer,str1);
//strcpy() 函数不是赋值所有内容,只是复制\0(包含这个符号)之前的内容。
字符串的拼接
string str = "hello world";
char str2[]="hello world-";
string str3=str2;
char a[128];
sprintf(a,"%s%d",str3.c_str(),3);//%@
printf("%s\n",a);