#include "stdafx.h"标签:abc,基础知识,char,123,printf,字符串,input,指针 From: https://blog.51cto.com/u_21817/6066897
int main(int argc, char* argv[])
{
//定义字符串的第一种方式,此种定义的字符可修改
char a[] = "it";
a[0] = 'T';
printf("%s\n", a);
//定义字符串的第二种方式,常量字符串,不能修改
char *b = "abc";//b指向"abc"的首字符地址,即a的地址
char *c = "abc";
printf("%p___%p\n", b, c);//b和c,指向字符的地址。*b和*c指向的地址相同
printf("%c\n", *b);//输出a
printf("%s\n", b);//输出abc,b不带*号
//字符串数组
char *names[3] = {"abc", "def", "ghi"};
//也可这样:
char names2[2][3] = {{"123", "123", "123"}, {"123","123","123"}};
//输入字符串
char input[20];
printf("请输入:");
scanf("%s", input);
printf("%s", input);
return 0;
}