[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Interview Questions and Answers :: Alcatel-Lucent

1. Can you write a program to implement memcpy. copy must be successful even source and destination address overlap.

Answer:

As given copy should be successful even source and dest address overlap, than we should implement memmove functionality

void ownMemMove(void *dest, void *src, size_t n)
{

char *src_l = (char *)src;
char *dest_l = (char *)dest;

char *temp [n];

memset(temp, '\0', n);

for (int i=0; i < n; i++)
temp[i] = src_l[i];

for (int i=0; i < n; i++)
dest_l[i] = temp[i];

}

Post Your Answer Here:      Public      Private

Rate This: +1 -0
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here