Cisco Systems Interview Question for Software Engineer / Developers






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

This is the correct way:
char* strcyp(char* dst, const char* src)
{
char* ret = dst;
while(*dst++=*src++);
return ret;
}

- ldiamond February 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

while(*src!='/0')
{

des=src;

src++;

}

- Anonymous November 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assuming des has allocated space just like strcpy

int n = 0;
while ( *src != '\0' )
{
   *des++ = *src++;
   n++;   
}
return n;

- Anonymous November 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char *temp=src;

while((*dst++=*src++)!='\0');
return(src-temp-1);

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

I think, its a strcpy(), so you need to append a '\0' at the end, none of the programs listed above are doing that.

- Bond, James Bond March 22, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think in C, No null-character is implicitly appended to the end of destination in strcpy, so destination will only be null-terminated if the length of the C string in source is less than num. You have to clarify this with the interviewer as to what he wants

- Avinash February 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the catch here is to check if the source and destination memory overlap or not, which requires calculating the len including '\0'. And possibly using memcpy to copy the amount of non overlapping mem size in loop until it copies completely.

- SP July 31, 2014 | Flag Reply


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