so would this be the right way?
Code:
int trans;
printf("\n Which transaction type is needed? (0-5)");
scanf("%d", &trans);
switch(trans) {
case 0:
printf("Enter a key and name, respectively.");
scanf("%d%d", &theId, &theName);
theTest1 = 0;
theTest2 = 0;
theTest3 = 0;
theHwCount = 0;
theHwPoints = 0;
break;
case 1:
printf("Enter value for test 1");
scanf("%d", &theTest1);
break;
case 2:
printf("Enter value for test 2");
scanf("%d", &theTest2);
break;
case 3:
printf("Enter a value for test 3");
scanf("%d", &theTest3);
break;
case4:
printf("Enter a value for homework count");
scanf("%d", &theHwCount);
printf("Any additional points for homework? (0 -> 5)");
scanf("%d", &theHwPoints);
break;
case 5:
printf("Enter a value for extra homework points, not exceeding 5 times actual homework count");
scanf("%d", &theHwPoints);
break;
}
I also have a question or two about the code you posted earlier:
in this struct:
Code:
struct Student * getOneStudentFromData ( ) {
struct Student * aStudentPtr;
int scanned, theId, theTest1, theTest2, theTest3, theHwCount, theHwPoints;
char theName [7];
char cr;
fscanf (infile, "%d%s%d%d%d%d%d%c",
&theId, theName, &theTest1, &theTest2, &theTest3,
&theHwCount, &theHwPoints, &cr);
you have int scanned, but thats the only place I ever see 'scanned' in the whole code, what is it for?
and what does the char cr refer to?