This involves structures. Basically I created an array of structures and I am supposed to pass it onto a function that was given. This is where my problem is (marked /*HERE*/). I think I am passing it onto the function incorrectly. This is the error I get:
warning C4133: 'function' : incompatible types - from 'struct Player [8]' to 'struct Player *'
Im not exactly sure what that means. something to do with passing on a pointer? Could someone help me out? What do I need to pass to the function?
I think I assured myself that I created the array properly by using printf statements.
NOTE: the two functions printBracket and getIndex were given, so they cannot be changed.
Let me know if I need to explain better.
Code:#include <stdio.h> #include <stdlib.h> #include <string.h> /*FUNCTION PROTOTYPES*/ void printBracket( struct Player x []); int getIndex( char c ); int main(){ //initialize variables struct Player{ char major; char name[10]; int seed; }; struct Player array[8]; int count=1; char person[10]; char subject; int junkChar; //Print statement printf("Welcome to MARCH MADNESS!\n\nPlease enter the 8 player names, " "followed by their major code and seed.\n\n(For major enter a single " "character from the major code key:\n\n\t" "'e' for ECE, 'h' for ChE, 'm' for MIE\n\t" "'c' for CEE, 'b' for BME, 'u' for Und )\n"); while(count<=8){ //while loop to get users inputs printf("Enter the number %d seed's name (10 chars max):",count); //prompt for name scanf("%s",&person); printf("Enter %s's major code: ",person);//prompt for major scanf("%c",&junkChar); scanf("%c",&subject); strcpy(array[count-1].name,("%s",person)); array[count-1].major=subject; array[count-1].seed=count; count++; //add 1 to counter } //end while printBracket(array); /*HERE*/ return 0; //indicate program ended successfully } //end function main /**FUNCTIONS**/ //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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



LinkBack URL
About LinkBacks



