⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adder.c

📁 小型web服务器
💻 C
字号:
/* * adder.c - a minimal CGI program that adds two numbers together *//* $begin adder */#include "csapp.h"int main(void) {    char *buf, *p;    char arg1[MAXLINE], arg2[MAXLINE], content[MAXLINE];    int n1=0, n2=0;    /* Extract the two arguments */    if ((buf = getenv("QUERY_STRING")) != NULL) {	p = strchr(buf, '&');	*p = '\0';	strcpy(arg1, buf);	strcpy(arg2, p+1);	n1 = atoi(arg1);	n2 = atoi(arg2);    }    /* Make the response body */    sprintf(content, "Welcome to add.com: ");    sprintf(content, "%sTHE Internet addition portal.\r\n<p>", content);    sprintf(content, "%sThe answer is: %d + %d = %d\r\n<p>", 	    content, n1, n2, n1 + n2);    sprintf(content, "%sThanks for visiting!\r\n", content);      /* Generate the HTTP response */    printf("Content-length: %d\r\n", strlen(content));    printf("Content-type: text/html\r\n\r\n");    printf("%s", content);    fflush(stdout);    exit(0);}/* $end adder */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -