有人可以解释为什么会出现seg故障(C编程)吗?

use*_*600 5 c segmentation-fault

int load_byte(int memory[],int address) {
//This function works by finding the appropriate word then masking
//to obtain the relevant byte
int index,section;

    switch (address>>28) {
        case 0:
            index = address - START_ADDRESS;
            printf("index = %d",index);
        case 1:
            index = address - START_DATA_ADDRESS;
        case 7:
            index = address - START_STACK_ADDRESS;
   }

    section = index%4;
    index = index/4;
    switch (section) {
    case 0:
        return memory[index]&0x000000ff;
    case 1:
        return (memory[index]&0x0000ff00)>>8;
    case 2:
        return (memory[index]&0x00ff0000)>>16;
    case 3:
        return (memory[index]&0xff000000)>>24;
    }
Run Code Online (Sandbox Code Playgroud)

}

START_ADDRESS的值为0x00400000,我使用的样本地址是0x00400002,只是这个函数不断给我一个seg错误,不太明白为什么有问题的数组大小为1000.提前感谢.

Wer*_*nze 8

你的第一个开关看起来很奇怪,只处理0,1和7.break;每个案件的最后都没有陈述.