I have a problem in function let_comment. Function should add comments to movies defined in structures movie and comment.
Compiler show error in line f->comments.text=text;
error: (COMMENT*)&f->comments' is a pointer;did you mean to use '->'
#include <stdio.h>
#include <stdlib.h>
typedef struct comment {char text[256], name[64];} COMMENT;
typedef struct movie {char name[64]; double mark;COMMENT comments[50];} MOVIE;
int let_comment(MOVIE *, char *, char *);
int main()
{
MOVIE *p_movie;
//int koment_true;
char text1[256],name1[64];
char *p_text=text1,*p_name=name1;
p_movie=(MOVIE*)malloc(5*sizeof(MOVIE));
printf ("Inout movie data:\n");
for(int i=0;i<5;i++)
{
printf ("Name: "); scanf("%s",(p_movie+i)->name);
}
for(int i=0;i<5;i++) {let_comment((p_movie+i),p_text,p_name);}
}
int let_comment(MOVIE *f, char *text, char *name)
{
printf("Input comment: ");scanf("%s",text);
printf("Comment editor: ");scanf("%s",name);
f->comments.text=text;
f->comments.name=name;
}
`
I were expecting that line f->comments.text=text;
to assign comment to movie.comments.text
field in structures.