In cPP, the array is passed to the pointer as a parameter.

topic description

how to pass an array as an argument to a pointer to a function or what is the solution

sources of topics and their own ideas

output the questions of a member by a student class

related codes

/ / Please paste the code text below (do not replace the code with pictures)
class Student
{
public:
void get_name (char * name)
{

  this->name = name;

}
private:
char name [28];
};

Void main ()
{
Student s [40];
char name [10];
cin > > name;
s [1]. An error occurred here in get_name (name); / /
reason: pointer address error
}

what result do you expect? What is the error message actually seen?

what is the reason and how to solve it?

CPP
Aug.31,2021

CPP is still in std::string like other high-level languages.
if you use the char array alone, it's more like using C, you need to write and copy the string yourself.
this- > name = name;// is wrong here, wrong type.

it is recommended that you use std::string to store strings.
and your get_name should be changed to set_name to be more semantic (at least in most programming, the assignment is set instead of get).

-sharpinclude <string>;

class Student {
    std::string name;
public:
    //   char *   std::string  std::string
    void set_name(const std::string &name) {
        this->name = name;
    }
};
Menu