Undefined array in struct
Hi there.
I am confused as to why the following piece of code does work:
Code:
#include<stdio.h>
#include<stdlib.h>
struct my_struct
{
char my_word[];
int num;
};
int main()
{
struct my_struct eg;
eg.my_word[3] = 'y';
eg.my_word[67] = 'w';
printf("\n %c \n %c \n %c \n", eg.my_word[3], eg.my_word[67], eg.my_word[54]);
system("pause");
}
The array in the struct is not assigned a maximum size. Outside of a struct this is not allowed. This behaviour is not mentioned in my text book.
Why is this?
Many thanks,
WVM