001-调用函数访问结构体数组成员,并修改其数值

1 代码

/*
    调用函数访问结构体数组成员,并修改其数值
*/
#include <stdio.h>     /* for printf */
#include <stdlib.h>    /* for exit */

struct mytest{
   char a ;
   char b ;
   char c ;
};

void p_find_test(struct mytest *aaa)
{
    struct mytest *test = aaa+1;
    test->a = 6;
    test->b = 7;
    test->c = 8;
}

int main(void)
{
    struct mytest test01[3];
    test01[1].a=2;
    test01[1].b=2;
    test01[1].c=2;
    printf("a: %d\n",test01[1].a);
    printf("b: %d\n",test01[1].b);
    printf("c: %d\n",test01[1].c);
    p_find_test(test01);
    printf("a: %d\n",test01[1].a);
    printf("b: %d\n",test01[1].b);
    printf("c: %d\n",test01[1].c);

    exit(EXIT_SUCCESS);
}

2 运行结果