> Is it normal behavior, or sign for a bug?
when you declare variable "i" you change position of mybuffer
pointer on the stack. mybuffer is not initialized, so it points on
some random address. if you are lucky it can point to some allocated
memory and the program works. but it is a bug in your code.
you should allocate a buffer on the stack, for example like this:
or dynamically using malloc:
in this case don't forget to free it after usage: