下面的 C++ 程序会生成 cpp_radiobutton.cgi 脚本,用于处理 Web 浏览器通过单选按钮给出的输入。
实例
#include<iostream>#include<vector> #include<string> #include<stdio.h> #include<stdlib.h>#include<cgicc/CgiDefs.h>#include<cgicc/Cgicc.h>#include<cgicc/HTTPHTMLHeader.h>#include<cgicc/HTMLClasses.h>usingnamespacestd;usingnamespacecgicc; intmain(){ CgiccformData; cout << "Content-type:text/html\r\n\r\n"; cout << "\n"; cout << "\n"; cout << "向 CGI 程序传递单选按钮数据\n"; cout << "\n"; cout << "\n"; form_iteratorfi = formData.getElement("subject"); if( !fi->isEmpty() && fi != (*formData).end()){ cout << "Radio box selected: " << **fi << endl; } cout << "
\n"; cout << "\n"; cout << "\n"; return0;}