明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

CGI圖文說明教程(7)解碼數(shù)據(jù)發(fā)送給CGI腳本之3

[摘要]解碼數(shù)據(jù)發(fā)送給CGI腳本下面舉個(gè)例字,如果QUERY_STRING包含以下內(nèi)容:tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three 那么以下的程序?qū)⒈痪幾g和運(yùn)行: enum boo...
解碼數(shù)據(jù)發(fā)送給CGI腳本

下面舉個(gè)例字,如果QUERY_STRING包含以下內(nèi)容:

tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three

那么以下的程序?qū)⒈痪幾g和運(yùn)行:

enum bool { false, true };

#include

#include

#include "parse.h"

#include "parse.cpp"

void main()

{

char *query_str = getenv("QUERY_STRING");

Parse list( query_str );

cout << "name = " << list.get_item_n( "name" ) << "\n";

cout << "action= " << list.get_item_n( "action" ) << "\n";

cout << "log = " << list.get_item_n( "log", 1, true ) << "\n";

for ( int i=1; i<=4; i++ )

{

cout << "tag (" << i << ") = ";

cout << list.get_item_n( "tag" , i ) << "\n";

}

}

結(jié)果它的輸出為:

name = mike

action= +10%

log = /usr/staff/mas/log

tag (1) = one

tag (2) = two

tag (3) = three

tag (4) =