Last active
July 13, 2017 15:39
-
-
Save HyodaKazuaki/1dd00bf7a97b4912c0be5b087751cb9d to your computer and use it in GitHub Desktop.
C++でのCGIプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
template <typename ... Args> | |
void cprintf(const char *format, Args const & ... args); | |
int main(void) | |
{ | |
cprintf("Content-type: text/html"); | |
cprintf(""); | |
cprintf("<!DOCTYPE HTML>"); | |
cprintf("<html lang=\"ja\">"); | |
cprintf("<head>"); | |
cprintf("<meta charset=\"UTF-8\">"); | |
cprintf("<title>Test Page</title>"); | |
cprintf("</head>"); | |
cprintf("<body>"); | |
cprintf("<h1>Test page</h1>"); | |
cprintf("<p>"); | |
cprintf("This is test page.<br>"); | |
cprintf("テストページ"); | |
cprintf("</p>"); | |
cprintf("</body>"); | |
cprintf("</html>"); | |
return 0; | |
} | |
template <typename ... Args> | |
void cprintf(const char *format, Args const & ... args) | |
{ | |
char s[4095]; | |
sprintf(s, "%s\r\n", format); | |
printf(s, args ...); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment