basic
\0: for the end of the string
NUL: 是一个数值为0的控制字符,是\0的转义字符
char string[7] = {'h', 'e', 'l', 'l', 'o', '\0'};
/*the total length is 5 + 1
在c语言内部,是这么储存的
char string[] = "hello"
/*这里就不用加入\0了
#include <stdio.h>
int main()
{
/* define a string and print*/
char name[] = "hello";
printf("bussiness: %s\n", name);
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
/*define three string with the same length*/
char str1[14] = "runoob";
char str2[14] = "google";
char str3[14];
int len;
/*copy str1 to str3*/
strcpy(str3, str1);
printf("new one is %s\n", str3);
/*connect str1 to str2*/
strcat(str2, str1);
printf("new one is %s\n", str2);
/*the length after connecting*/
len = strlen(str2);
printf("the length is %d\n", len);
return 0;
}