#include <iostream> #include <string> #include <vector> #include <cstdio> #include <cstring> using namespace std; int main() { char *Cstr = (char *)malloc(128); vector <string> AllLine; while (gets(Cstr)) { AllLine.push_back(string(Cstr)); if (!strcmp(Cstr, "</xmp>")) { delete Cstr; break; } memset(Cstr, 0, 128); } int count = AllLine.size(); char *prucuctName = (char *)malloc(128); for (int i = 0; i < count; i++) { string str = AllLine[i]; if (strstr(str.c_str(), "h3")) { char *ch = new char[128]; memcpy(ch, AllLine[i].c_str(), 128); sscanf(ch, "%*[^>]>%[^<]", prucuctName); continue; } if (strstr(str.c_str(), "In Stock")) { string output(prucuctName); cout << output << endl; } } getchar(); } |
Double click to view unformatted code.