test_get.c
来自「程序代码使用说明: (1)所有源代码目录下都提供了Makefile(非Qt)」· C语言 代码 · 共 44 行
C
44 行
#include <stdio.h>#include <stdlib.h>#define MAX_ARG 150int main(){ /* get arguments */ char *buf = getenv("QUERY_STRING"); if (buf == NULL) exit (1); char para1[MAX_ARG], para2[MAX_ARG]; char value1[MAX_ARG], value2[MAX_ARG]; /* parse '&' */ char *p = strchr(buf, '&'); *p = '\0'; strcpy(para1, buf); strcpy(para2, p + 1); /* parse the first '=' */ p = strchr(para1, '='); *p = '\0'; strcpy(value1, p + 1); /* parse the second '=' */ p = strchr(para2, '='); *p = '\0'; strcpy(value2, p + 1); printf("Content-type: text/html\n\n"); printf("<HTML><HEAD><TITLE>CGI TEST RESULT</TITLE></HEAD>\n"); printf("<BODY><H2>get test string from GET</H2><PRE>\n"); printf("The first parameter is: %s\n<p>", para1); printf("The first value is: %s\n<p>", value1); printf("The second parameter is: %s\n<p>", para2); printf("The second value is: %s\n<p>", value2); printf("</PRE></BODY></HTML>\n"); fflush(stdout); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?