I'm having a problem that is probably silly but I do not understand why it does not work despite its simplicity.
Having a struct
composed of the components of a vector in 3D, I only wanted to show one of them after I typed it and yet it shows me a gigantic value:
struct vector3D
{
double x, y, z;
};
int main()
{
vector3D v;
printf("Introduce las tres componentes de un vector3D");
printf("\nComp. 1: "); scanf("%f", &v.x);
printf("Comp. 2: "); scanf("%f", &v.y);
printf("Comp. 3: "); scanf("%f", &v.z);
printf("%f", v.x); // Aquí muestra un valor que no tiene nada que ver con lo
// que he tecleado previamente y me impide hacer otros cálculos
return 0;
}
I do not know if I have declared something wrong or what. I appreciate your attention. Greetings.