Problematic program:
#include<stdio.h>
#include<string.h>
void main() {
char s[100],f[1];
scanf("%s",&s);
scanf("%s",&f);
printf("\n%s %s",s,f);
}
output is empty for s, while f is read properly.
while if we switch f[1]
and s[100]
, or initialise f with size larger than 1, or initialize any other larger than 1 array, then it works as it should.
(this is a stripped down version of program, to the essential problematic part)
tried swapping f[1] and s[100] which works, but when placed in the mentioned order, it breaks.