C语言中的单引号和双引号含义迥异,用单引号引起的一个字符实际上代表一个整数,整数值对应于该字符在编译器采用的字符集中的序列值,因此,采用ASCII字符集的编译器而言,‘a’的含义与0141或97严格一致。而用双引号引起的字符串,代表的却是一个指向无名数组起始字符的指针,该数组被双引号之间的字符以及一个额外的二进制值为零的字符‘\0’初始化。
#include <stdio.h>
#include <stdlib.h> int main(int argc, const char *argv[]) {
struct stu {
int num;
char *name;
char gender;
float score;
} *ps;
ps = (struct stu*)malloc(sizeof(struct stu));
ps->num = ;
ps->name = 'peeeeeeee'; //双引号是全部引用字符串 单引号是引用ASC码
ps->gender = 'M';
ps->score = 62.2;
printf("%d %s", ps->num, ps->name);
printf("%c %f", ps->gender, ps->score);
free(ps);
return ;
}
编译报错,最开始没有注意,后来才想起C语言的单引号和双引号区别
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAecAAAA/CAIAAABVdZf1AAATsUlEQVR4nO1d6bMVxRWfP2b+lCyVVKeIC4tgXMKSSmlKO8vXBFMWH5KYqqTLEgxBUQHREAOtKSWmQoSAiEJJgzx46jPAWwjG5YIm35IPPT3TyzndPXPnvvu49/xqquDdme4+c6b716dPd58uDp5Z0tf7126u38JLH1wOZPjrsoIJNdBQgo1XlOUEonn98xCfRaipUiOBMGkoXnpnQV+zSzfu2vJw8ACXhjDHIN20wnRTI+gvmVBj74YJBMIQKA6cmtfX7NKNdZtD1iZMAurRypSNVwiECUTx4smr+rq0OFi76aFxy0MgEAiEGIr9b17V18WFwZqNxNoEAoGwolHsf3NeXxcXbqzZSB4SAoFAWNEo9p9c1NfFxZtrNtE01S0BLrV72vxblmW11CY+0cg4b/F0T+Aye16VCRU63sEf/RLq/JlQ9cPRhTZmmh1Gjve/qwqzFTL8N+KyRQZhcankXNp3ubT0xoTK/ubeg62EnkoUL7x1TV8XF79Yu+mH45aHEAGzJhUDluFO7WfQ+j6b/8AHRgWnd0HhLm8xrdmlXowM6pbevBeXSjDOseaPU3ou4XRdjpO9atP9RnA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