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

Write a recursive program to calculate factorial in c++.

859


A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

3493


Can you Mention some Application of C/C++?

853


If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

1286


What is a literal in c++?

780


What is the difference between public and private data members?

933


Do class declarations end with a semicolon?

834


How to declaring variables in c++?

921


What is abstract keyword in c++?

865


Is c++ platform dependent?

873


Can union be self referenced?

883


How is computer programming useful in real life?

822


You want to link a c++ program to c functions. How would you do it?

767


What are the two types of comments?

793


Is c++ a difficult language?

813