Please help find the error in this code.
It probably obvious but I cant seem to find the mistake.
Its a simple call to a function with an array address, but somehow the subsequent addresses of the array elements get messed up.
Please help, urgently needed for a school project.
Thanks a lot.
________________________________________
Code:
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
//Declarations
typedef float point3D[3]; // declare a point data type for 3D points
typedef float vector3D[3]; // declare a vector data type for 3D vectors
void getNormal(vector3D *normal, point3D p1, point3D p2, point3D p3)
{
*normal[0]=-10;
*normal[1]=-2;
*normal[2]=2;
printf("The addresses inside the function: %i %i %i \n", normal[0], normal[1], normal[2]);
printf("The values inside the function: %f %f %f \n\n", *normal[0], *normal[1], *normal[2]);
}
void main()
{
//Let P0 = (1, 0, 2) P1 = (2, 3, 0) P2 = (1, 2, 4)
point3D
p0 = {1,0,2},
p1 = {2,3,0},
p2 = {1,2,4};
vector3D n;
getNormal(&n, p0, p1, p2);
printf("The addresses returned : %i %i %i \n", &n[0], &n[1], &n[2]);
printf("The values returned : %f %f %f \n\n", n[0], n[1], n[2]);;
}