#include <iostream>
using namespace std;
struct test{
char charr[5];};
int main(){
test t{
.charr="ss"};
cout<<" "<<t.charr<<endl;
return 0;
}
//result
error: C99 designator 'charr' outside aggregate initializer
.charr="ss"};
初始化结构体出现这个错误 error: C99 designator 'xx' outside aggregate initializer
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
快乐鹦鹉 2022-03-19 16:51关注#include <iostream> #include <string.h> using namespace std; struct test{ char charr[5];}; int main(){ test t; strcpy(t.charr,"ss"); cout<<" "<<t.charr<<endl; return 0; }评论 打赏 举报解决 1无用