As you can see in this part of my code:
#include <stdio.h>
#include <stdlib.h>
struct s_box
{
int matnr;
double vol;
int pos[2];
};
int main ()
{
int matnr2;
double vol2;
int pos2[2];
typedef struct s_box *pt_box;
pt_box *p,*q;
p = (pt_box *)malloc(sizeof(pt_box));
q = (pt_box *)malloc(sizeof(pt_box));
printf("Write a value for: \nMaterialnr= ");
scanf("%d",&matnr2);
printf("\nVolumen = ");
scanf("%fl",&vol2);
printf("\nxPos =");
scanf("%d",&pos2[0]);
printf("\nyPos =");
scanf("%d",&pos2[1]);
printf("\nzPos =");
scanf("%d",&pos2[2]);
//on the next line is my question:
p -> matnr = matnr2; //Codeblox gives me the next "error:'*p' is a pointer; did you mean to use '->'?"
p->vol = vol2;//same error
p->pos = pos2[0],pos2[1],pos2[2]);//same error
printf("MaterialNr = \t%d/nVolumen = \t%f m^3\nPosition = (%d,%d,%d)",p->matnr,p->vol,p->pos[0],p->pos[1],p->pos[2]);
// my target is to print the data stored in *p on the screen.
}
So the question is about the error: "did you mean to use '->'?" I already use it and Codeblox does not accept it. So what do I have to change and print the data on the screen after entering it from the keyboard.
P.S. I started learning C one week ago.