#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char * argv[])
{

// 字符串指针定义
char a[] = "abcdefg";//数据保存在栈里,可修改
char *str = "abcdefg";//保存的是常量,不能修改
printf("%d\n",sizeof(str));// = 8;指的是指针地址大小
printf("%d\n",strlen(str));// = 7;

str = "gBGg";
printf("%d\n",sizeof(str));// = 8;
printf("%d\n",strlen(str));// = 4;
printf("%c\n",*(str+2));//=G;
//打印每个字符
for (int i = 0; i < strlen(str); i ++) {
printf("%c\t", *(str+i));//g B G g
}
printf("\n");

char chs[] = "kkkdddfff";//可修改
chs[2]='G';
printf("%s\n",chs);

//1如何让定义的字符串指针可输入
char *p = NULL;
p = malloc(100);
scanf("%s",p);
printf("%s",p);
//2如何让定义的字符串指针可输入
char *pp[100];
scanf("%s",pp);
printf("%s",pp);

printf("\n");
return 0;
}