Interview Question

Staff Software Engineer Interview Bangalore (India)

Write a function to perform string copy using pointers

Answer

Interview Answer

1 Answer

0

void main()
{
 char* string1="Hello there";
    char* string2 = (char*)malloc(sizeof(strlen(string1)));
    copyString(string1,string2);
}

void copyString(char* x, char* y)
{
int i=0;
while(x[i]!=0)
{
y[i]=x[i];i++;
}

y[i]=0;

}

Interview Candidate on Jul 4, 2012

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up