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
Define private, protected and public access control.
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
What is linked list in c++?
Differentiate between a constructor and a destructor in c++.
What does the linker do?
what kind of projects are suitable for c and c++
Define namespace in c++?
Can union be self referenced?
Are php strings immutable?
What is pair in c++?
Explain linear search.
What will happen if a pointer is deleted twice?
Is linux written in c or c++?
How can you say that a template is better than a base class?
Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?