1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <stdio.h>
void printS(char *str)
{
puts(str);
}
void printF(float *f)
{
printf("%f\n", *f);
}
struct GLFrame
{
int x, y, z;
void (*func1)(char *);
void (*func2)(struct GLFrame *, int *, int *, int *);
};
void modPos(struct GLFrame *frame, int *x, int *y, int *z)
{
frame->x = *x;
frame->y = *y;
frame->z = *z;
}
struct GLFrame frame = {
.x = 5,
.y = 6,
.z = 7,
.func1 = printS,
.func2 = modPos
};
int main(void)
{
#if 0
float x = 1.0f;
printf("x in hex: 0x%016x\n", x);
#endif
int x, y, z;
x = y = z = 3;
/* i want to modify position vector, xyz */
frame.func2(&frame, &x, &y, &z);
printf("x is: %d\ny is: %d\nz is: %d\n", frame.x, frame.y, frame.z);
puts("Hello");
return 0;
}
|