C language problem: 0xc0000005: access conflict occurred when writing to location 0xffffcc.

Recently, I began to learn C language systematically and use scanf in vs2019_ An error occurred when s assigned a value to a string. The error is as follows:
the exception raised at the location of 0x7837ef8c (ucrtbased. DLL) (located in project2.exe): 0xc0000005: an access conflict occurred when writing to the location of 0x01342000
*
after querying some data, we find that this problem should be solved because scanf is encouraged in vs2019 compiler_ S function to prevent the original scanf function array out of bounds( Using scanf function in vs2019 will report an error (compilation failed)

#define WORD_SIZE 26
char name[WORD_SIZE];
scanf_s("%s",name);

If so, an error will be reported.

If we provide the array name and length, we can compile it.

#define WORD_SIZE 26
char name[WORD_SIZE];
scanf_s("%s",name,WORD_SIZE);


Read More: