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...

Implement strncpy

Answer Posted / ada

char *my_strncpy( char *dst, char *src, size_t n)
{
int i = n;
char *p = dst;

if(!dst || !src)
return dst;

while( i != 0 && *src != '\0' )
{
*p++ = *src++;
i --;
}

while( i!=0 )
{
*p++ = '\0';
i --;
}

return dst;
}

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the history of c++?

1081


What is difference between c++ and c ++ 14?

1060


Why do we use structure in c++?

1086


Describe the advantage of an external iterator.

1042


What is type of 'this' pointer? Explain when it is get created?

1017


What is bubble sort c++?

1015


Explain the differences between private, public and protected and give examples.

1025


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

1202


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

1042


Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

2533


What is auto used for in c++?

1055


Explain how to initialize a const member data.

1041


Write is a binary search tree? Write an algo and tell complexity?

1027


What is virtual destructor ans explain its use?

1134


Why we use #include iostream in c++?

1062