以下程序崩溃。 我究竟做错了什么?
#include <stdio.h> #include <process.h> int main() { puts("Hello!"); return spawnlp(0, "notepad.exe", "notepad.exe", "test.txt"); }
您错过了作为参数列表的一部分传递的终止NULL。
如果没有这个终结符,参数列表的末尾将不会被知道,系统会继续读取,由于访问无效的内存位置而导致未定义的行为 。