Poj 3753 first top embedded cup finals question

Source: Internet
Author: User

// 7915734 vrs570540852 3753 accepted 368 K 0 Ms GCC 1169b 18:36:18
// Poj question a of the first top embedded Cup Finals of 3753
# 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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.