I am trying to print the x value for newBall, but don't understand how to access it. Can someone help me out? I have a pointer to a struct Ball within the struct AllBalls. I get a compile error saying x is not a member of a structure.
#include <stdlib.h>
#include <stdio.h>
struct Ball {
char id;
double x;
double y;
double Vx;
double Vy;
};
struct AllBalls {
int count;
struct Ball *ballPtr;
};
int main(void)
{
int index = 1;
struct AllBalls list = {0, NULL};
struct Ball newBall;
double x, y, Vx, Vy;
int input;
printf("Enter input: ");
input = scanf("%lf %lf %lf %lf", &x, &y, &Vx, &Vy);
list.count++;
list.ballPtr = &newBall;
newBall.id = 64 + list.count;
newBall.x = x;
newBall.y = y;
newBall.Vx = Vx;
newBall.Vy = Vy;
printf("%lf", *(list.ballPtr).x);
}