I have stumbled upon strange behaviour in following C program.
#include <stdio.h>
void main(void) {
int ta = 0;
int te;
int ca;
char fna[1];
char e[12];
FILE *fa = fopen("list.txt", "r");
ca = fgetc(fa);
while(ca != 10) {
fna[ta] = ca;
te = ta + 1;
ta = te;
ca = fgetc(fa);
}
fclose(fa);
}
list.txt can contain any line, with a newline.
the fna char limit is ignored and program runs successfully even if line contains more than 1 characters.
If I delete the declaration of e[12], the expected error starts to occur. (Also if I lower the variable e limit, error starts to occur too. Even though e is not used at all.
What can cause this issue? It seems that variable fna lends e's character space.