下面的 C++ 程序会生成 cpp_textarea.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("textcontent"); if( !fi->isEmpty() && fi != (*formData).end()){ cout << "Text Content: " << **fi << endl; }else{ cout << "No text entered" << endl; } cout << "
\n"; cout << "\n"; cout << "\n"; return0;}