Here's what I have. It should work from what I can tell, but it has a little bit of a problem printing the bracket. Also there's a few warning messages, which I am pretty sure are because I'm sending i down to the swoopinfo function
Code:
swoopinfo(firstname,i,&theirmajor);
.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* structure for player info*/
struct Player {
int seed;
char name[11];
char major;
};
typedef struct Player Player; //won't have to type in "struct" all 1 times in the main...sure was worth it
void printBracket(Player x []); //prints the brackets
int getIndex( char c ); //used in printBracket
void swoopinfo(char *, char *); //function to get player info from user
int main()
{
Player list[9];
int i=1;
char firstname[11];
char theirmajor;
printf("Please enter the 8 player names,\n followed by their major code and seed.\n"
"For major enter a single character from the major code key:\n\n"
"'e' for ECE 'h' for ChE \n'm' for MIE 'c' for CEE\n 'b' for BME 'u' for Und \n\n\n");
/* run swoopinfo function, set player info for each player, move to next seed*/
for (i=1;i<9;i++)
{
swoopinfo(firstname,i,&theirmajor);
list [i].seed = i;
strcpy (list [i].name, firstname);
list [i].major = theirmajor;
}
printBracket(list); //print the bracket
return(0);
}
/**************************************FUNCTIONS**/
void swoopinfo(char nameptr [],int i, char *majorptr)
{
char dummy;
printf("Enter seed #%d's name: ",i);
scanf("%s", nameptr); //used in main
printf("Enter %s's major: ", nameptr);
scanf("%c", &dummy); //need a buffer apparently
scanf("%c", &majorptr); //used in main
}
//*******************************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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\