I can imagine a two dimensional array as a contagious sequence of bytes. My question is, can it be treated as a one dimensional array with explicit cast without invoking undefined behavior?
I have tested the following code with gcc and it ran normally and didn't crash. What does the standard say about it?
int main(void)
{
char buf[2][5];
strcpy((char *)buf, "link 101");
printf("%s\n", (char *)buf);
return 0;
}
Just saying, I have good reason to think of this.