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
What is difference between structure and union in c programming?
what is the difference between class and unio?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
If I have a char * variable pointing to the name of a function ..
Should I learn c before c++?
What is a stream?
What are the different types of data structures in c?
what is event driven software and what is procedural driven software?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
How do I create a directory? How do I remove a directory (and its contents)?
What are types of preprocessor in c?
Do pointers need to be initialized?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
When is a null pointer used?
Can a pointer be static?