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;
    }
};
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38a00-2c120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38a00-2c120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?