So I am working on a program, I'm a net admin and terrible at programming, and need some help with structures, arrays, and possibly pointers. I am trying to write a program using struct, I know I need arrays but I am not sure how to properly tie them in with the struct. All info needs to be user input and needs to break on command to either skip to end or Loop back to certain point to enter more info. I need the user to input the employee ID#, then be able input multiple review scores, like 100, 90, 80, then break that sequence and either go back and enter another employee# and keep going, or skip to the end and print out all info entered.
The employee ID number and score entry seems to work fine when entering but when I print it out it does not look right so I am obviously doing something wrong with how the data is being stored and then printed. code and results below.
#include <stdio.h>
struct help{
int empID;
int marks[100];
};
int main(){
struct help s[100];
int i, input, empNUM;
NEWENTRY: printf("Enter employee ID#: ");
scanf("%d", &empNUM);
for(i=0;i<10;++i){
s[i].empID = empNUM;
printf("\nFor employee ID# %d\n",s[i].empID);
while (i <= 100) {
printf("Enter score:");
if (scanf("%d", &input) == 1) {
if (input >= 0 && input <= 100) {
s[i].marks[100] = input;
i++;
}
else if (input == 101) {
printf("\n\nExiting entry.\n");
i = i - 1;
goto NEWENTRY;
}
else if (input == 102) {
printf("\n\nExiting entry.\n");
i = i - 1;
goto EXIT;
}
}
}
}
EXIT:
for(i=0;i<10;++i) {
printf("\nInformation for employee ID number %d:\n",s[i].empID);
printf("Marks: %.1f",s[i].marks);
}
return 0;
}
I would like it to look remotely like this if possible.
info for emp id 12345:
100
90
80
info for emp id 67890:
80
90
60