Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C++でのCGIプログラム
#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