关于结构体的小白问题
#include <stdio.h>#include <stdlib.h>
struct a{
int a;
char b;
char c[];
};
int main (void)
{
struct a *p=(struct a *)malloc(sizeof(struct a)+24*sizeof(char));
p->a=1;
p->a='c';
p->c="nihao";
printf("%s",p->c);
free(p);
}
请问大家,用指针给字符串赋值怎么赋啊,p->c="nihao";不好使,编译器提示error: incompatible types in assignment of `const char[6]' to `char[0u]',啥意思呢。到底用指针给结构体中的伸缩性数组赋值,该怎么赋值呢?