结构体的部分初始化不能啊
#include<stdio.h>struct Book
{
char title;
char author;
float price;
unsigned int data;
char publisher;
}book={
book.price=48.8,
book.data=20171111,
book.publisher="清华大学出版社"
};
int main()
{
struct Book book;
printf("%d\n",book.data);
printf("%s\n",book.publisher);
} #include<stdio.h>
struct Book
{
char title;
char author;
float price;
unsigned int data;
char publisher;
}book={
.price=48.8,
.data=20171111,
.publisher="清华大学出版社"
};
int main()
{
struct Book book;
printf("%d\n",book.data);
printf("%s\n",book.publisher);
} 永恒的蓝色梦想 发表于 2020-10-14 20:48
也是出错了 永恒的蓝色梦想 发表于 2020-10-14 20:48
C99 designator 'publisher' outside aggregate initializer 长虹灬冰魄 发表于 2020-10-14 20:51
也是出错了
应该是你的编译器不支持,换编译器吧
https://fishc.com.cn/thread-175256-1-1.html
之后把 C++标准 调到最新就好 长虹灬冰魄 发表于 2020-10-14 20:51
C99 designator 'publisher' outside aggregate initializer
下到我c盘去了 裂开
页:
[1]