各位:
请帮忙看看这段代码:red linux 7下可通过,red linux 9下通不过.
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
using namespace std;
class Applicant
{
public:
string name, city, address, phone, mail;
};
class WebProcess
{
public:
string input;
string dest[5];
Applicant app;
// get the value of "QUERY_STRING"
void get()
{
input.assign(getenv("QUERY_STRING"));
}
void replaceAll(const string &findstr, const string &replstr)
{
int found = input.find(findstr);
while(found != string::npos)
{
input.replace(found, findstr.length(), replstr);
found = input.find(findstr);
}
}
void urldecode()
{
replaceAll("%2C", ",");
replaceAll("+", " ");
split();
}
void split()
{
int count = 0;
char *p;
p = strtok(input.begin(), "&");
while(p != NULL)
{
dest[count] = p;
count++;
p = strtok(0, "&");
}
for(int counter = 0; counter != count; counter++)
{
dest[counter].erase(0, dest[counter].find("=")+1);
}
app.name = dest[0];
app.city = dest[1];
app.address = dest[2];
app.phone = dest[3];
app.mail = dest[4];
}
void save()
{
ofstream file;
file.open("test.dat", ios:ut|ios::app);
file.write((char *)&app, sizeof(app));
file.close();
}
void display()
{
cout << "Content-type:text/html"<<endl<<endl;
cout << "<html>";
cout << "<body>";
cout << "<h1>";
cout << "The details saved are :" << "<br>";
cout << "</h1>";
cout << "name is: " << app.name << "<br>";
cout << "city is: " << app.city << "<br>";
cout << "address is: " << app.address << "<br>";
cout << "phone is: " << app.phone << "<br>";
cout << "mail is: " << app.mail << "<br><br><br><br><br>";
cout << "<h2>Your details have been recorded</h2>";
cout << "<h1>THANKS !!!!</h1>";
cout << "</body>";
cout << "</html>";
}
};
int main()
{
WebProcess web;
web.get();
web.urldecode();
web.split();
web.save();
web.display();
return 0;
}
提示出错如下:
13d2.cc:48: cannot convert `__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to
`char*' for argument `1' to `char* strtok(char*, const char*)' |