C language character array overflow does not report error

-sharpinclude <stdio.h>
void f(void){
    char a[8];
    char b[8];
    scanf("%s",a);
    scanf("%s",b);
    printf("%s-sharp-sharp%s-sharp-sharp\n",a,b);
} 
int main(void){
    f();
    return 0;
} 
As for the

beginner c language
code, I defined two character arrays of length 8. But why can I still output normally when I enter characters longer than 8?
for example, when I type "123123123 123123123", pirntf comes out with "123123123-sharp-sharp123123123-sharp-sharp", and the specified number of digits has no effect.
ask seniors for advice.

Mar.31,2021

because the c language itself does not have an array overflow check, scanf does not know how big the array you defined is, and for the f function, as long as it does not exceed the stack size assigned to it, it will not report an error.

Menu