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
How do you declare A pointer to a function which receives nothing and returns nothing
Who was the creator of c++?
What's c++ used for?
Explain about vectors in c ++?
What new()is different from malloc()?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
Why is c++ awesome?
Differentiate between late binding and early binding.
What is iterator in c++?
Write a program which uses Command Line Arguments
How do you find out if a linked-list has an end? (I.e. The list is not a cycle)
Using a smart pointer can we iterate through a container?
Describe linked list using C++ with an example.
Is there structure in c++?
What is the difference between prefix and postfix versions of operator++()?