i get this error on any line with dot notation. Oh, and do I need to use
cin.getline(boy .name)?:
error:'.':left operand points to 'struct' use '->'
This is the program in question:
#include<iostre am.h>
#include<string .h>
#define MAX 20
#define ARRAY 4
struct monkey {
char name[MAX];
int age;
float weight;
};
void main()
{
struct monkey boy[ARRAY];
int index;
for(index=0; index<ARRAY; index++)
{
cout<<"MONKEY BOY "<<(index+1 )<<" :"<<endl;
cout<<"Enter the name: ";
cin>>boy.name;
cout<<endl<<"En ter the age: ";
cin>>boy.age;
cout<<endl<<"En ter the weight: ";
cin>>boy.weight ;
cout<<endl<<end l;
}
}
Does anybody know what is wrong?
cin.getline(boy .name)?:
error:'.':left operand points to 'struct' use '->'
This is the program in question:
#include<iostre am.h>
#include<string .h>
#define MAX 20
#define ARRAY 4
struct monkey {
char name[MAX];
int age;
float weight;
};
void main()
{
struct monkey boy[ARRAY];
int index;
for(index=0; index<ARRAY; index++)
{
cout<<"MONKEY BOY "<<(index+1 )<<" :"<<endl;
cout<<"Enter the name: ";
cin>>boy.name;
cout<<endl<<"En ter the age: ";
cin>>boy.age;
cout<<endl<<"En ter the weight: ";
cin>>boy.weight ;
cout<<endl<<end l;
}
}
Does anybody know what is wrong?
Comment