在C语言中 printf("Contenttype:text/html\n\n")是什么意思

如题所述

在C语言中,printf("Contenttype:text/html\n\n")表示输出字符串"Contenttype:text/html\n\n",其中,\n表示回车字符。也即输出如下内容
Contenttype:text/html
[回车]
[回车]
ps:[回车]不会出现在输出中,[回车]表示空行

printf()函数是格式化输出函数, 一般用于向标准输出设备按规定格式输出信息。
printf()函数的调用格式为:
printf("<格式化字符串>", <参量表>)
对于字符串输出,则直接调用printf("待输出字符串"),如:
printf("Contenttype:text/html\n\n");
对于输出参数值的,则调用printf("<格式化字符串>", <参量表>),如:
int a=5;
printf("%d", a); // 输出参数a的值
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-06-04
就是要在标准输出流中写入"Content type:text/html"这样一个文本
如果在C语言中写,应该是一个服务端为网页生成页面的程序,它的标准输出应该定位到了一个socket或者一个文件。
第2个回答  2012-02-28
Now let's modify hello.pl so it will run as a CGI script. Every CGI script needs to output a special header as the first thing the script outputs. This header line is checked by the Web server, then passed on to the remote user invoking the script in order to tell that user's browser what type of file to expect. Most of the time, your script is going to output an HTML file, which means you'll need to output the following header:

print "Content-type: text/html\n\n";

这只是一个文件头而已,告诉浏览器,我传过来的是HTML格式的文件。
第3个回答  2011-07-24
是不是sprintf或fprintf?printf输出到标准输出了,即stdout,一般stdout定义为屏幕了,所以在屏幕显示。可以更改stdout到文件。sprintf打印到字符串,fprintf打印到文件。
输出的内容就是html头吧?
应该是C写的web服务器。
第4个回答  2011-07-22
输出语句,输出为:
Contenttype:text/html

press any key to continue追问

汗, 当然不是这么简单啊,这是一个CGI程序

追答

......
可它这句还就是这个意思...

本回答被网友采纳
相似回答