Answer Posted / lylez00
#include <string.h>
/* strncpy */
char *(strncpy)(char *restrict s1, const char *restrict s2,
size_t n)
{
char *dst = s1;
const char *src = s2;
/* Copy bytes, one at a time. */
while (n > 0) {
n--;
if ((*dst++ = *src++) == '\0') {
/* If we get here, we found a null character at
the end
of s2, so use memset to put null bytes at
the end of
s1. */
memset(dst, '\0', n);
break;
}
}
return s1;
}
Is This Answer Correct ? | 1 Yes | 5 No |
Post New Answer View All Answers
write a programme to get a character and thier ASCII value
What is the prototype of printf function?
Is c++ a good beginners programming language?
Explain stack unwinding.
What is stack unwinding?
What is this weird colon-member (" : ") syntax in the constructor?
Can manipulators fall in love?
What is iterator c++?
Can we run c program in turbo c++?
Who calls main function?
How to implement is-a and has-a class relationships?
What are static variables?
What is basic if statement syntax?
Which is most difficult programming language?
What is data structure in c++?