// TestString.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "string"
#include "stack"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char *LongS="you are My love";
char *Find="My";
stack<char> MyStack;
char *phead=LongS;
char *rear=phead;
char *p=Find;
while(*phead!='/0')
{
while(*phead==*p)
{
phead++;
p++;
}
if(*p=='/0')
{
for(char *temp=phead-1;temp>=rear;temp--)
MyStack.push(*temp);
rear=phead;
p=Find;
}
else
{
MyStack.push(*rear++);
phead=rear;
p=Find;
}
}
while(!MyStack.empty())
{
cout<<MyStack.top();
MyStack.pop();
}
cin.get();
return 0;
}