hey i did as you asked and it seems to be working!...btw what type of compiler do you recommend jweoblewski44?
Code:
#include <stdio.h>
typedef struct{
char name[50];
int age;
char gender[50];
int position;
}ind; //Individual
void input(ind I[], int n);
void output(ind I[], int n);
void input(ind I[], int n)
{
int x;
for(x=0; x<n; x++)
{
printf("Enter name: ");
scanf("%s", I[x].name);
printf("Enter age: ");
scanf("%d", &I[x].age);
printf("Enter gender: ");
scanf("%s", I[x].gender);
printf("Enter position: ");
scanf("%d", &I[x].position);
}
}
void output(ind I[], int n)
{
int x;
for(x=0; x<n; x++)
{
printf("NAME: %s\n", I[x].name);
printf("AGE: %d\n", I[x].age);
printf("GENDER: %s\n", I[x].gender);
printf("POSITION: %d\n\n", I[x].position);
}
}
int main()
{
int n;
printf("Enter number of registered individuals: ");
scanf("%d", &n);
ind I[n];
int opt;
do{
printf("1. Add\n2. View\n3. Exit\n\n");
printf("Option: ");
scanf("%d", &opt);
switch(opt)
{
case 1:
input(I, n);
break;
case 2:
output(I, n);
break;
case 3:
break;
default:
printf("INVALID\n\n");
break;
}
}while(opt!=3);
}