#include "stdio.h"
#include "string.h" // strcpy()
typedef struct
{
int no;
char name[10];
} student, *pstudent;
pstudent struct_call_by_address(pstudent pboy)
{
pboy->no = 10;
strcpy(pboy->name, "oomusou");
printf("[in] function:\n");
printf("no=%d, name=%s\n", pboy->no, pboy->name);
printf("=====================\n");
return pboy;
}
int main()
{
student boy = {20, "John"};
pstudent pboy = 0;
printf("[before] function\n");
printf("no=%d, name=%s\n", boy.no, boy.name);
printf("=====================\n");
pboy = struct_call_by_address(&boy);
printf("[after] function\n");
printf("*boy* no=%d, name=%s\n", boy.no, boy.name);
printf("*pboy* no=%d, name=%s\n", pboy->no, pboy->name);
printf("=====================\n");
}
=====Result=====
沒有留言:
張貼留言