Cisco Systems Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
3
of 3 vote

void memcpy( void *pDst, void *pSrc, int len )
{
int i;

if( pDst == NULL || pSrc == NULL )
return;

for( i=0; i<len; i++ )
{
((unsigned char*)pDst)[i] = ((unsigned char*)pSrc)[i];
}
}

- Anonymous February 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char* memcpy(char arr2[], char arr1[], arr1Len) { //char can be replaced by any other datatype
    int i = 0;
    for (i = 0; i < arr1Len+1; i++) {
        arr2[i] = arr1[i];
    }
    return(arr2);
}

- Anonymous January 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You haven't taken care for the memory overlap case guys. What if pSrc < pDst+len?

- Nithish March 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

memcpy doesn't take of overlap ... memmove takes care of it

- Janus April 04, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void memcpy(void *dst, void *src, size_t len)
{
// if(!dst||!src) ... ; not sure if this is needed.
char* dst_c = (char*)dst;
char* src_c = (char*)src;
while(len--) {*dst++=*src++;}
}

- biostanley October 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void * memcpy(void * dst, void * src, size_t count)
;       {
;               void * ret = dst;
;
;               if (dst <= src || dst >= (src + count)) {
;                       /*
;                        * Non-Overlapping Buffers
;                        * copy from lower addresses to higher addresses
;                        */
;                       while (count--)
;                               *dst++ = *src++;
;                       }
;               else {
;                       /*
;                        * Overlapping Buffers
;                        * copy from higher addresses to lower addresses
;                        */
;                       dst += count - 1;
;                       src += count - 1;
;
;                       while (count--)
;                               *dst-- = *src--;
;                       }
;
;               return(ret);
;       }

- johnsvakel November 24, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How can we de-reference void pointers?

- Anonymous December 13, 2018 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More