A
Acacia
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<iostream.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<<"Enter the age: ";
cin>>boy.age;
cout<<endl<<"Enter the weight: ";
cin>>boy.weight;
cout<<endl<<endl;
}
}
Does anybody know what is wrong?
cin.getline(boy.name)?:
error:'.':left operand points to 'struct' use '->'
This is the program in question:
#include<iostream.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<<"Enter the age: ";
cin>>boy.age;
cout<<endl<<"Enter the weight: ";
cin>>boy.weight;
cout<<endl<<endl;
}
}
Does anybody know what is wrong?