I've already read a somewhat similar question (why this code works in C) but it doesn't actually gets to explain why is this piece of code actually working:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct example
{
char length[2];
} STRUCT;
int main (void)
{
STRUCT test;
strcpy(test.length, "********");
puts(test.length);
return 0;
}
I'm using CodeBlocks to compile it, so I guess it is allocating more space in my string to store the extra asterisks by default... I really don't know. Maybe I'm just lucky, but everytime I run it it works.
In the example (link) I showed above he put 2 elements in an array of 2, here I'm using a lot of more space than the string can handle, or could.