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
What is function prototyping? What are its advantages?
What is a class template?
Do you know about C++ 11 standard?
What are all predefined data types in c++?
Is it possible for a member function to use delete this?
What are friend classes? What are advantages of using friend classes?
What is function overloading in C++?
Why is main an int?
How a new operator differs from the operator new?
What are the advantage of using register variables?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
Which is not a valid keyword a) public b) protected c) guarded
Why is c++ is better than c?
What are the 2 main types of data structures?
What is buffer and example?