阅读背景:

关于指向固定数组的指针的困惑

来源:互联网 

Consider following example:

请考虑以下示例:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct test_t {
    char (*p)[20];
} test;

int main(int argc, char **argv) {
    test t;

    t.p = malloc(2 * sizeof(*t.p));

    strcpy(t.p[0], "hello");

    strcpy(t.p[1], "world");

    printf("[%s]\n", t.p[0]);
    printf("[%s]\n", t.p[1]);

    free(t.p);
}
#inclu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: