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 does it mean to declare a member function as static?

614


List different attributes in C++?

643


What is java and c++?

669


What are the 2 main types of data structures?

590


What is an adjust field format flag?

648






Describe the syntax of single inheritance in C++?

651


What is recursion?

663


What is general format for a prototype?

601


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

572


what you know about c++?

667


What is null c++?

590


What are the four main data types?

589


Which software is used for c++ programming?

620


What is abstract keyword in c++?

595


Explain the scope of resolution operator.

633