Hi! I am a beginner in C++. This is little assignment. It gives an
error "Structure Require on Left Side of dot operator" Can anybody help
me what went wrong in this code?
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void set(void);
void display(void);
struct subject
{
char sub_id[50];
int credit;
};
struct student
{
int roll_no;
char name[50];
subject sub[3];
};
student st[3];
void main (void)
{
clrscr();
set();
display();
getch();
}
void set (void)
{
for (int i=0; i<=3-1; i++)
{
cout<<"\n\tEnter Roll No. = ";cin>>st[i].roll_no;
cout<<"\n\tEnter Name = ";gets(st[i].name);
for (int j=0; j<=3-1; j++)
cout<<"\n\tEnter Subject: "<<j+1<<" = "; gets(st.sub[j].sub_id);
cout<<"\n\tCredit ";cin>>(st.sub[j]).credit;
}
}
void display (void)
{
for (int i=0; i<=3-1; i++)
{
cout<<"\n\t Roll No. = "<<st[i].roll_no;
cout<<"\n\tName = ";puts(st[i].name);
for (int j=0; j<=3-1; j++)
cout<<"\n\t Subject: "<<j+1<<" = ";puts((st.sub[j]).sub_id);
cout<<"\n\tCredit "<<(st.sub[j]).credit;
}
}