开发者

Why I initialise a struct in this way make my phone crashed?

I defined a struct:

typedef struct myStruct{
   int32 iMem1;
   int16 sMem2;
   int32 iMem3;
}myStruct;

And initialise it:

void main(){
   myStruct s1 = {0, 1, 0};
   return 0;
}

When I run it in my phone, it crashed my phone.

If I initialise it another way:

void main(){
    myStruct s1 = {0};
    return 0;
}

Everything is ok!

I doub开发者_Python百科t about it!


Both struct initializations are fine, assuming int32 and int16 are types. However, main must return an int:

int main()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜