指针,结构,C ++,在函数中编写新结构

时间:2015-05-23 07:47:58

标签: c++ arrays pointers struct

有人可以解释我以下错误并告诉我如何修复它们(写成评论)?

我的结构:

const int max = 1000;
const int MAX = 30;

struct student_t
{
    int k; 
    char* name[MAX];  
    char** bez[MAX]; 
};

使用此函数,我必须编写此结构的成员(成员< = 1000)和bez。 (< = 30)每个成员:

int write (student_t *field[max], int i)
{
    student_t *pointerfield= new student_t;
    printf("Number:....");  
    std::cin>>pointerfield->number;
    if (pointerfield->number>1 && pointerfield->k<999999)
    {
        if (binarsearch(&field[max],i,(pointerfield->number))!=-1)
        {
            return i;
        }
        else
        {
            printf("\nName:.....");
            readstr();
            pointerfield->name=readstr(); 

            // insupportable types of allocation of int to char* [30]

            std::cout<<std::endl;
            int counter=0;
            std::cout<<"Do you want to add bez.? j,n"<<std::endl;
            char a;
            std::cin>>a;

            if(a=='j' && counter<MAX)
            {
                std::cout<<"Bez.:";
                readstr();
                pointerfield->bez[MAX]=readstr();

                // char *  can not be converted into assignment to char ** 

                counter++;
            }
            // ...

0 个答案:

没有答案