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
When can a far pointer be used?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
What is the use of typedef in structure in c?
Is c# a good language?
Explain what is the benefit of using const for declaring constants?
write a programming in c to find the sum of all elements in an array through function.
Why is c called "mother" language?
Can you write the algorithm for Queue?
How can you convert integers to binary or hexadecimal?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What does %c mean in c?
How can you return multiple values from a function?
how to find anagram without using string functions using only loops in c programming
How can I do graphics in c?