not sure how to use struct.. please help

//DEBUG1 Program
// This program creates a structure to hold data for a kennel
#include<iostream.h>


struct KennelList
{
int dogID;
char gender;
int age;
};

void main()
{
KennelList dogs[5];
for(int x=0;x<5;++x)
{
cout<<"Enter dog's 3-digit ID:"<<endl;
cin>>dogs.dogID;
cout<<"Gender M or F:"<<endl;
cin>>dogs.gender;
cout<<"Age:"<<endl;
cin>>dogs.age;
}


for(x=0;x<5;++x)
{
cout<<dogs[x].dogId;
cout<<" Gender "<<dogs[x].gender<<" Age "<<dogs[x].Age<<endl;
}
}
You are not being very clear in what it is that you are having a problem with.
But, I'll use an example to help you. please use "[" code "]" (insert text here) "[" /code "]" tags like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <math.h>
#include <iostream>
using namespace std;
struct
SomeStruct //name
{
  //instance data 
    int x; 
    int y;
    int z;
};

//program driver
int main()
{
//declare an instance of the struct
SomeStruct pos;//name the struct anything

 //use the dot "." operator to access data members of the struct

//lets f*** around with things, lol
pos.x = (int) cos( 30 * 180.0/3.14 ); //assignment "=" operator - does an operation
pos.y = (int) sin( 60 * 180.0/3.14 );
pos.z = (int) tan( 45 * 180.0/3.14 );

std::cout << pos.x << std::endl;
std::cout << pos.y << std::endl;
std::cout << pos.z << std::endl;
 
   return 0;
}


From what I see of your code, which i didn't compile, I detected no errors.

Use this site to Test it: http://ideone.com/
Last edited on
ALSO...

void main() does not exist. int main() and int main(int,char**) do exist. Its not java :)
Topic archived. No new replies allowed.