Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is difference between structure and union in c programming?

1017


what is the difference between class and unio?

2305


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1071


If I have a char * variable pointing to the name of a function ..

1113


Should I learn c before c++?

1177


What is a stream?

1078


What are the different types of data structures in c?

1111


what is event driven software and what is procedural driven software?

2508


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

2740


How do I create a directory? How do I remove a directory (and its contents)?

1098


What are types of preprocessor in c?

1015


Do pointers need to be initialized?

1018


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

1833


When is a null pointer used?

1062


Can a pointer be static?

1022