Hello friends, programmers club wishes u all a very warm pongal greetings...may u have all the prosperity in life and fortune go by ur way......hope u all had a fun filled break until now......it might jus be d last holiday for most of us....so do finish it of on a high note....nd get back to work more positively,with more energy and a lot of courage ......wish u all gud luck...have a gr8 lyf ahead.....happy coding mates!!
1) Given the following code snippet, what does the function DoesWhat()
ReplyDeletedo? And what, if any, assumptions are made about the input to the
function.
struct _tagElement
{
int m_cRef;
unsigned char m_bData[20];
struct _tagElement * m_next;
} NODE, * PNODE;
PNODE DoesWhat (PNODE pn1, PNODE pn2)
{
PNODE * ppnV = &pn1;
PNODE * ppn1 = &pn1;
PNODE * ppn2 = &pn2;
for ( ; *ppn1 || *ppn2; ppn1 = &((*ppn1)->m_next))
{
if (!(*ppn1) || (0 < memcmp((*ppn1)->m_bData,
(*ppn2)->m_bData, sizeof((*ppn2)->m_bData))))
{
PNODE pn = *ppn1;
*ppn1 = *ppn2;
pn2 = (*ppn2)->m_next;
(*ppn1)->m_next = pn;
}
}
return *ppnV;
}
2) What are the problems with the quality of the previous code and how
would you make it better? Please try to find as many problems as you
can.
3) Write the code for the function below. Parameters data and filter
are null-terminated strings. Scan removes all occurrences of the
string filter from the string data.
int scan(char *data, char *filter);