views:

26

answers:

1

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 doubt about it!

Thanks.

A: 

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

int main()
Matthew Flaschen
Thanks, but I think it's nothing to do with main, because I use int main(), it also crash my phone.I think it's the struct's alignment(int16, int32) cause the crash, but I doubt about it.
TideHunter