C CGI程序的Apache错误

C CGI程序的Apache错误,c,apache,cgi,C,Apache,Cgi,我试图用C语言编写一个CGI程序,我正在学习,这似乎是一件有趣的事情,我遇到了Apache/CGI错误的问题,但只有一行非常具体。如果这一行被注释或删除,它的效果会非常好,但如果它被包括在内,它每次都会爆炸 struct site_link { char *name; char *url; }; struct blog_data { char *blog_name; struct site_link *links; } blog; blog.blog_name

我试图用C语言编写一个CGI程序,我正在学习,这似乎是一件有趣的事情,我遇到了Apache/CGI错误的问题,但只有一行非常具体。如果这一行被注释或删除,它的效果会非常好,但如果它被包括在内,它每次都会爆炸

struct site_link
{
    char *name;
    char *url;
};

struct blog_data
{
    char *blog_name;
    struct site_link *links;
} blog;

blog.blog_name = "richardwagner.io";
blog.links[0].url = "Home"; // <-- this line right here
blog.links[0].name = "Home";
blog.links[1].url = "Posts";
blog.links[1].name = "Posts";
blog.links[2].url = "About";
blog.links[2].name = "About";
打开“调试”级别日志记录的Apache日志

[Mon Dec 15 10:27:38.906961 2014] [authz_core:debug] [pid 63010] mod_authz_core.c(799): [client 192.168.1.104:49922] AH01626: authorization result of Require all granted: granted
[Mon Dec 15 10:27:38.906982 2014] [authz_core:debug] [pid 63010] mod_authz_core.c(799): [client 192.168.1.104:49922] AH01626: authorization result of <RequireAny>: granted
[Mon Dec 15 10:27:38.907020 2014] [authz_core:debug] [pid 63010] mod_authz_core.c(799): [client 192.168.1.104:49922] AH01626: authorization result of Require all granted: granted
[Mon Dec 15 10:27:38.907026 2014] [authz_core:debug] [pid 63010] mod_authz_core.c(799): [client 192.168.1.104:49922] AH01626: authorization result of <RequireAny>: granted
[Mon Dec 15 10:27:39.186804 2014] [cgi:error] [pid 63010] [client 192.168.1.104:49922] End of script output before headers: tblog

几天来,我一直在努力解决这个问题,但我就是不能让这一行很好地发挥作用,即使对我来说,它似乎与下面的其他几行几乎相同。

你缺少\r\n\r\n来表示标题的结尾。

我知道我会忘记一些事情。我还有一行内容类型blah blah,就在前面。比如:printfContent-type:text/html\r\n\r\n;//???生成的错误和记录的错误是相同的。在命令行上运行CGI,并将输出放在pastebin/gist中