educative.io

Strncpy( ) -> function signature

The strncpy() function in this section seems wrong. The basic syntax of the strncpy() function is given below:

char* strncpy(const char *str2, const char *str1, int n);

In this case the destination str2 is a immutable because it is prefixed by keyword “const” which does not make sense here. Since the destination will be modified by copying the contents of str1 into location pointed by str2, it can’t be const char * right?


Course: Advanced Programming Techniques in C - Learn Interactively
Lesson: Standard Library Functions - Advanced Programming Techniques in C