C++ - class issue

前端 未结 6 1632
灰色年华
灰色年华 2021-01-24 19:33

At: http://www.learncpp.com/cpp-tutorial/82-classes-and-class-members/

There is the following program (I made some small modifications):

#include 

        
6条回答
  •  终归单人心
    2021-01-24 19:46

    The error is because strncpy is declared in the cstring header file.

    A pointer is used because you are working with C strings, which are char arrays. Arrays in C are used through pointers. And strncpy takes two pointers to char(char arrays) to do the copy process.

提交回复
热议问题