<<thread split>>
#include <stdio.h>
struct a
{
char aa;
char ab;
char ac;
};
struct b
{
char b_a;
char b_b;
char b_c;
char b_d;
char b_e;
char b_data[1];
};
int main()
{
struct b data_s;
struct a *req;
req =(struct a* )data_s.b_data;
req->aa=3;
req->ab=3;
req->ac=25;
printf("%x\n",data_s.b_data[0]);
printf("%x\n",data_s.b_data[1]);
printf("0x%x\n",data_s.b_data[2]);
return 0;
}
Hi I am writing a Driver Code where the situation is like this as above.My doubt in this is that am I doing an array overflow here to the 'char variable b_data' ?? Can anyone please able to tell actually how the stack is getting populated in this case.Or is it a Stack Overflow ?? If I do "int ac" instead of "char ac" of "struct a" the program will crash in that case.I am thinking why is it so ??
I am a bit confused please help me out.The program is running successully in the OpenVMS Operating System.
Thanks in Advance,
Shubh,