Created
November 22, 2018 12:22
-
-
Save unbit/8bf6ff8a4967eb152a65c929829ee4cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct vector3 { | |
float x; | |
float y; | |
float z; | |
}; | |
struct vector3 vector3_add(struct vector3 v0, struct vector3 v1) { | |
struct vector3 new_vec; | |
new_vec.x = v0.x + v1.x; | |
new_vec.y = v0.y + v1.y; | |
new_vec.z = v0.z + v1.z; | |
return new_vec; | |
} | |
void vector3_init(struct vector3 *v0, float x, float y, float z) { | |
v0->x = x; | |
v0->y = y; | |
v0->z = z; | |
} | |
int main(int argc, char **argv) { | |
struct vector3 va; | |
struct vector3 vb; | |
struct vector3 vd; | |
struct vector3 *vshit = &vd; | |
vector3_init(&va, 1, 2, 3); | |
vector3_init(&vb, 4, 5, 6); | |
vector3_init(vshit, 4, 5, 6); | |
struct vector3 vc = vector3_add(va, vb); | |
printf("vector3 %f %f %f\n", vc.x, vc.y, vc.z); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment