为什么这个 sprintf_s 会抛出异常?

Why does this sprintf_s throw an exception?

char filePrefix[] = "test";
char fileName[100]; fileName[0] = 0;
sprintf_s(fileName, "%s", filePrefix);

我不明白为什么在 sprintf_s

中写入 fileName 时出现异常
Exception thrown at 0x00007FF885E3F3A9 (ucrtbased.dll) in foo.exe: 0xC0000005: Access violation writing location 0x0000008331F00000.

documentation 开始,sprintf_s 的第二个参数应该是目标缓冲区的大小。

char filePrefix[] = "test";
char fileName[100];
fileName[0] = 0;
sprintf_s(fileName, sizeof fileName, "%s", filePrefix);