I am compiling and running this code:
// hello, world!, without printf
#include <stdio.h>
#include <string.h>
char a[7] = "hello, ";
char b[7] = "world!\n";
void putCharArray(char *ray) {
for (int i = 0 ; i < strlen(ray) ; i++ )
{ putchar(ray[i]); }
}
void main() {
putCharArray(a);
}
on Ubuntu 20 using gcc. When it runs it outputs:
hello, world!
So it seem like it runs past the 'a' array and right into the 'b' array.
Would someone please explain how that is? Please and thank you.