couple problems with structures
Here's the assignment:
"You must create a structure called Player, that contains each of the following variables:
- A string called name that has a maximum size of 10 characters.
- A character called major that corresponds to a particular major within engineering. The key is as follows:
e = ECE
m = MIE
c = CEE
h = ChE
b = BME
u = Und
- And an integer called seed that indicates the pre-tournament ranking of each player (from 1 – 8).
Your program must create an array of 8 Player structures. Then, you must create a function to allow the user to input each of the players’ name and major. You will need to provide error checking code for the major variable. The major variable will need to be checked to make sure it is one of the acceptable characters listed above.
Have the user input the players’ information in seed order. That is, enter the number one seed’s information first, then the number two seed, etc. Your array should be filled in this order as well (i.e. number one seed in array index 0, number two seed in array index 1...etc.).
Finally, you will call the printBracket function to display the bracket as it currently stands. "
I know that what I have so far has some big errors, but don't knwo how to fix any of them. What am I doing wrong?
Code:
#include <stdio.h>
/**************************************FUNCTION PROTOTYPES**/
void printBracket( struct Player x []);
int getIndex( char c );
void swoopinfo(char *, char *);
struct player {
int seed;
char name[11];
char major;
};
typedef struct player Player;
int main()
{
int i=1;
char firstname;
char theirmajor;
printf("Please enter the 8 player names, followed by their major code and seed. \n For major enter a single character from the major code key:\n'e' for ECE, 'h' for ChE, 'm' for MIE\n'c' for CEE, 'b' for BME, 'u' for Und \n");
for (i=1;i<9;i++)
{
void swoopinfo(&firstname,&theirmajor);
Player i= {i,firstname,theirmajor};
}
}
/**************************************FUNCTIONS**/
void swoopinfo(char *nameptr, char *majorptr)
{
printf("enter name: ");
scanf("%s", *nameptr);
printf("enter %s's major: ", *nameptr);
scanf("%c", *majorptr);
}
//*******************************FUNCTION: printBracket
//*******************************ARGUMENTS: ( struct Player [] ): Array of team structures sorted by seed
//*******************************RETURN: void
//*******************************DESCRIPTION: prints out bracket image of sorted array of players
void printBracket( struct Player x [] )
{
char * maj[6]= {"ECE", "ChE", "MIE", "CEE", "BME", "Und"}; //array used for indexing major
//PRINTING THE BRACKET
printf("\n\n");
printf("__%-10s_(%s)_(%d)_\n", x[0].name, maj[getIndex(x[0].major)], x[0].seed );
printf(" |_________\n");
printf("__%-10s_(%s)_(%d)_| |\n", x[7].name, maj[getIndex(x[7].major)], x[7].seed );
printf(" |_________\n");
printf("__%-10s_(%s)_(%d)_ | |\n", x[3].name, maj[getIndex(x[3].major)], x[3].seed );
printf(" |_________| |\n");
printf("__%-10s_(%s)_(%d)_| |\n", x[4].name, maj[getIndex(x[4].major)], x[4].seed );
printf(" |_________\n");
printf("__%-10s_(%s)_(%d)_ |\n", x[1].name, maj[getIndex(x[1].major)], x[1].seed );
printf(" |_________ |\n");
printf("__%-10s_(%s)_(%d)_| | |\n", x[6].name, maj[getIndex(x[6].major)], x[6].seed );
printf(" |_________|\n");
printf("__%-10s_(%s)_(%d)_ |\n", x[2].name, maj[getIndex(x[2].major)], x[2].seed );
printf(" |_________|\n");
printf("__%-10s_(%s)_(%d)_|\n", x[5].name, maj[getIndex(x[5].major)], x[5].seed );
}
/////////////////END OF printBracket FUNCTION\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//*******************************FUNCTION: getIndex
//*******************************ARGUMENTS: ( char ): character to index
//*******************************RETURN: int
//*******************************DESCRIPTION: returns the appropriate index of the major character in the string array of printBracket
int getIndex( char c )
{
switch( c )
{
case 'e':
case 'E':
return 0;
break;
case 'h':
case 'H':
return 1;
break;
case 'm':
case 'M':
return 2;
break;
case 'c':
case 'C':
return 3;
break;
case 'b':
case 'B':
return 4;
break;
case 'u':
case 'U':
return 5;
break;
default:
return 5;
}
}
/////////////////END OF getIndex FUNCTION\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\