Hi....i want to add data into a struct array and save it. how will i do this?i can get it to work.please help....
Code:
// STRUCTURES
struct CatRec {
char catname[10]; // Cat Name
char gender; // The Gender of the Cat: M,F
char type[20]; // Type of Cat
char color[10]; // The Color of the Cat
int age; // Age of Cat
char genuine; // Genuine Breed
};
void main()
{
struct CatRec Cats[100];
int choice;
int n=1;
do
{
clrscr();
choice = Menu(choice);
switch (choice)
{
case 1: clrscr();
AddCat(Cats,n);
break;
............... bla bla bla
void AddCat(struct CatRec Cats[],int &n)
{
char choice;
cprintf("Cat Name: ");
cin>>Cats[n].catname;
cprintf("\nGendar(M/F): ");
cin>>Cats[n].gender;
cprintf("\nBreed Type: ");
cin>>Cats[n].type;
cprintf("\nCat Color: ");
cin>>Cats[n].color;
cprintf("\nAge: ");
cin>>Cats[n].age;
cprintf("\nGenuine Breed(Y/N): ");
cin>>Cats[n].genuine;
cprintf("SAVE CHANGES(Y/N): ");
cin>>choice;
if (toupper(choice) == 'Y')
printf("SAVED");
else
printf("NOT SAVED");
getch();
}