View Code of Problem 98

#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <regex>

using namespace std;

int main()
{
	char str[128];
	vector <char *> AllLine;

	while (gets(str))
	{
		gets(str);
		char ch[] = "";
		int size = sizeof(str);
		char *iStr = new char[size];
		memcpy(iStr, str,size);
		AllLine.push_back(iStr);
		if (!strcmp(str, "</xmp>"))
		{
			delete iStr;
			break;
		}
	}

	int count = AllLine.size();

	char *prucuctName = (char *)malloc(255);

	char *p;
	for (int i = 0; i < count; i++)
	{
		string iStr =  AllLine[i];
		if (strstr(iStr.c_str(),"h3"))
		{
			char *ch = const_cast<char *>(iStr.c_str());
			sscanf(ch, "%*[^>]>%[^<]", prucuctName);

			/*p = strtok(const_cast<char *>(iStr.c_str()), ">");
			while (p)
			{
				string ik = p;
				if (strstr(p,"</"))
				{
					char *nameStr = strtok(p, "</");
					while (nameStr)
					{
						productName = nameStr;
						p = strtok(NULL, "</");
						break;
					}
				}
				p = strtok(NULL, ">");
			}*/
		}
		if (strstr(iStr.c_str(), "In Stock"))
		{
			cout << prucuctName << endl;
		}
	}
	system("pause");
}

Double click to view unformatted code.


Back to problem 98