code for copying two strings with out strcpy() function.
Answer Posted / reachhary
well, we could also have a string accepted at run time by
use of scanf.
To take care of such cases.
char *mystrcpy(char src[])
{
char *dest = NULL;
int indx = 0, len = 0;
if (!src) return dest;
len = strlen(src);
dest = (char *)malloc(sizeof(char) * len + 1);
while (; src[indx] ; dest[indx++]=src[indx]);
dest[indx]='\0'
return (dest)
}
Please do update if any one finds any issue with the code
segment - in terms of any error or any optimisation
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Describe explain how arrays can be passed to a user defined function
how to create duplicate link list using C???
Explain how can I avoid the abort, retry, fail messages?
What is variable declaration and definition in c?
What is function pointer c?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
How was c created?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
What is static function in c?
Write a program with dynamically allocation of variable.
What are different types of pointers?
What is function what are the types of function?
Why & is used in c?
What was noalias and what ever happened to it?
What is && in c programming?