1,char*: 表示指向字符串的指针,如char* str="hello";
2,char[ ]: 表示字符数组,如char str[ ]="world";
3,string: 字符串类型,在C++中是定义成一个数据类型,和int 、char一样,如string str="helloworld";但是在C语言中没有string类型变量。
#include<>里声明的函数原型也全是针对char数组的种种操作,没有对string数据类型声明。
4,char* 和char[ ]可以相互转换,如:char str1[ ]="hehe";char* str2=str1;
5,总结:a,C语言中字符串的表示就两种a char*, b char[ ]; string类型在C语言中是不存在的
b,in Linux C,we should set the end 0f char array(end tag is data 0),eg ,arr[end]=0; when using printf ("output array =: %s",arr),screen just show the string stored in rest of array will not show. if not do so,screen will show all the data in the rest of array are not assigned values,they are messy codes.
c,in C++,we needn't set the end of char array,system will do it.