fork download
  1. #include <stdio.h>
  2.  
  3. // This goes to the header file
  4.  
  5. typedef struct{
  6. float x,y,z;
  7. }vector;
  8.  
  9. vector vectorScale(float c, vector *v);
  10.  
  11. // This is implementation
  12.  
  13. inline vector vectorScale(float c, vector *v){
  14. return (vector){.x = v->x * c, .y = v->y * c, .z = v->z * c};
  15. }
  16.  
  17. int main(void) {
  18. vector v = {.x=1, .y=2, .z=3};
  19. vector w = vectorScale(5, &v);
  20. printf("%f %f %f\n", w.x, w.y, w.z);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
5.000000 10.000000 15.000000