📄 test_get.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -