首先解釋一下原因(來自知乎 問題鏈接)

圖片.png
test1:
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%d %s\n",10,NULL);
return 0;
}
輸出為: 10 (null)
test2:
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf(" %s\n",NULL);//%s前有空格
return 0;
}
輸出為: (null)
test3
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%s\n",NULL);//%s前無空格
return 0;
}
輸出為:段錯(cuò)誤 (核心已轉(zhuǎn)儲(chǔ))