NetApp Interview Question for Software Engineer / Developers






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

int strcpy(char *dest, char *src)
{
    char *from = src;
    char *to = dest;

    while(*from != \0)
    {
        *to = *from;
        to++;
        from++;
    }
    *to = \0;
}

- Anonymous March 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

no need to keep from pointer , waste register.
what if abs(dest-src)<strlen(src)?
what if *dest is NULL?

char * mystrcpy(char * t, const char *s)
{
   int size=strlen(s);
   char *t1=t;
   if(t==NULL) return NULL;
   if((t-s<=strlen(s))||(s-t<=strlen(s))) return NULL;
   while(*t++=*s++);
   return t1;
}

- Charles December 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Another question:
How do you make it faster ?
You are copying very byte, can you copy it with int?

- Charles December 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

No need to keep the "char* from", and it should return dest.

- Anonymous March 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char* strcpy(char* dest, const char* src)
{
char* first = dest;
while(*dest++ = *src++);
return first;
}

- Anonymous April 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The function needs to

1. Make sure that dest points to a valid memory address (for example, not null or 0) and

2. It has enough memory to hold all characters + null character from the source string.

3. There is no need to return anything. The function can be void if it is copying to the memory location passed via the argument.

- Arvind.Sinh May 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

xstrcpy(string str1, string str2)
{
char *s1 = str1; //target string
char *s2 = str2; //source string
while(*s2)
{
*s1 = *s2;
s1++; s2++;
}

cout << str1 ;
}

- gooty July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

xstrcpy(string str1, string str2)
{
char *s1 = str1; //target string
char *s2 = str2; //source string
while(*s2)
{
*s1 = *s2;
s1++; s2++;
}

cout << str1 ;
}

- gooty July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey99059" class="run-this">

void strcpy(char *dest, char *src)
{
while(*dest++ = *src++);
}</pre><pre title="CodeMonkey99059" input="yes">
</pre>

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

static string ImplementStrCpy(string src, string dest)
{
while(src != null)
{
dest = src;
break;
}
return dest;
}

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

dont we need to worry about memory allocation??

- Anonymous December 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void myStrcpy(char *src,char *dest)
{
    int i=0;
    
    *dest=*src;
    while(*src){
        *dest=*src;
        dest++;
        src++;
       // i++;
    }
    dest[i]='\0';
    
   // Complete this function

- mudit94 December 02, 2016 | 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