#include <stdio.h>
#include <stdlib.h>
int test(void)
{
int a=0,b=0;
char buf[4];
gets(buf);
printf("a:%d b:%d",a,b);
}
int main()
{
test();
return 0;
}
Question is why with input:aaaaa a is becoming 97 instead of b?From the way variables are declared inside test when buf overflows shouldn't it affect first b and then a?