简单的代码在C崩溃中产生进程.为什么?

7vu*_*0hy 1 c windows spawn

以下程序崩溃.我究竟做错了什么?

#include <stdio.h>
#include <process.h>

int main() {
    puts("Hello!");
    return spawnlp(0, "notepad.exe", "notepad.exe", "test.txt");
}
Run Code Online (Sandbox Code Playgroud)

Sou*_*osh 5

你错过了作为参数列表的一部分传递的终止NULL.

如果没有该终结符,参数列表的末尾将不会被知道,系统将继续读取,这会因访问无效的内存位置而导致未定义的行为.