为什么我无法访问struct中定义的数组指针?

时间:2018-01-08 16:04:51

标签: c arrays struct

我有以下结构:

typedef struct PCB_struct
    {
        Boolean valid;
        pid_t pid;
        pid_t ppid;
        unsigned ownerID;
        unsigned start;
        unsigned duration;
        unsigned usedCPU;
        processType_t type;
        status_t status;
        simInfo_t simInfo;
        unsigned size;              // size of logical process memory in pages
        int maxActivePages;
        int currActivePages;
        int activePages[maxActivePages];
        pageTableEntry_t *pageTable;
    } PCB_t;

此stuct将在方法调用

中初始化
void resetPCB (PCB_t *pcb)
{
    pcb->valid = FALSE;         
    pcb->pid = 0; 
    pcb->ppid = 0; 
    pcb->ownerID = 0;
    pcb->start = 0; 
    pcb->duration = 0; 
    pcb->usedCPU = 0; 
    pcb->type = foreground; 
    pcb->status = init;
    // pcb->simInfo;    // currently unused, 
                        // placeholder, but is not initialised
    pcb->size = 0;      // process has no physical memory allocated
    pcb->pageTable = NULL;
    pcb->maxActivePages = 2;
    pcb->currActivePages = 0;
    pcb->activePages = { 0 }; // this doesn't work
}

但是由于某些原因,当我定义指向该结构的指针时,我无法访问数组int activePages[maxActivePages]。我使用的是Visual Studio 2013.我做错了吗?

0 个答案:

没有答案