공부/C언어
3.[stm32f103][C언어] 구조체 포인터
유저라인
2017. 11. 29. 19:36
728x90
반응형
1, test1.c
#include "test.h"
void main()
{
test1_s test1;
test1.a = 10;
test1.b = 20;
test1.c = 30;
print_test(&test1);
}
2. test2.c
#include "test.h"
void print_test(unsigned int *val)
{
unsigned int pa, pb, pc;
pa = *val;
pb = *(val + 1);
pc = *(val + 2);
printf("%d\n", pa);
printf("%d\n", pb);
printf("%d\n", pc);
}
3. test.h
#include <stdio.h>
typedef struct
{
unsigned int a;
unsigned int b;
unsigned int c;
}test1_s;
void print_test(unsigned int *val);
4. 결과
728x90
반응형