//7915734 vrs570540852 3753 Accepted 368K 0MS GCC 1169B 2010-11-23 18:36:18
//POJ 3753 第一届顶嵌杯决赛 A题
#include<stdio.h>
#include<string.h>
#define NULL 0
int SafeStrcpy2KeyWord(char* pDestBuffer,
const char* pSourceString,
int nDestBufferSize,
char* szKeyWord)
{
if(pDestBuffer==NULL || pSourceString==NULL)
return 0;
char *sourceSta=(char*)pSourceString;
char *keySta=szKeyWord;
char *destSta=pDestBuffer;
int count=0;
int keylen;
if(keySta==0)
keylen=0;
else
keylen=strlen(keySta);
while(*sourceSta!='\0' && count<=nDestBufferSize)
{
if(count+keylen<=nDestBufferSize && keylen!=0 && !strncmp(sourceSta,keySta,keylen))
return count;
*destSta++=*sourceSta++;
count++;
}
return count;
}
int main()
{
char ptrDest[300]={0};
char ptrSource[300]={0};
char key[20]={0};
int count;
while(scanf("%s",&ptrSource)!=EOF)
{
while(scanf("%s",&key) && strcmp(key,"END\0"))
{
memset(ptrDest,0,sizeof(ptrDest));
if(!strcmp(key,"NULL\0"))
{
printf("0 NULL\n");
continue;
}
count=SafeStrcpy2KeyWord(ptrDest,ptrSource,260,key);
if(count==0)
printf("0 NULL\n");
else
printf("%d %s\n",count,ptrDest);
}
}
return 0;
}