Thread: Personal Program that is making me go wtf?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    14
    Yea I know my code is huge, but I'm not worrying about that right now....just trying to get things 2 work, will deal with it later. But, I have got it to save to the same file....but now in my team struct, I have an array of numbers which correspond to the ID numbers of the players in the team. I am wondering how to print those numbers stored in the array, so they can be used for when a player scores a goal and has their goal count increased, their worth increased etc...

    Code:
    void displayTeamPlayers(TeamInfo teams[MAX_TEAMS], int noOfTeams) {
    
    int print = 0;
    	int test;
    
    	char teamNameIn[STRING_LENGTH];
    
    	printf("Please enter the team: ");
    	scanf("%s", teamNameIn);
    	
    	for (print = 0; print < noOfTeams; print++) {	
    
    		if (strcmp(teams[print].teamName,teamNameIn)==0) {
    
    	ID1 = teams[print].player_array[0];
    			ID2 = teams[print].player_array[1];
    			ID3 = teams[print].player_array[2];
    			ID4 = teams[print].player_array[3];
    			ID5 = teams[print].player_array[4];
    			ID6 = teams[print].player_array[5];
    			ID7 = teams[print].player_array[6];
    			ID8 = teams[print].player_array[7];
    			ID9 = teams[print].player_array[8];
    			ID10 = teams[print].player_array[9];
    			ID11 = teams[print].player_array[10];  /*why can't I do this?*/
    
    printf("Team players \n");
    			printf("==================================================\n");
    			
    			printf("||Player1ID: %d \n", teams[print].player_array[0]);
    			//printf("%d\n", ID1);
    			printf("||Player2ID: %d \n", teams[print].player_array[1]);
    			//printf("%d\n", ID2);
    			printf("||Player3ID: %d \n", teams[print].player_array[2]);
    			//printf("%d\n", ID3);
    			printf("||Player4ID: %d \n", teams[print].player_array[3]);
    			//printf("%d\n", ID4);
    			printf("||Player5ID: %d \n", teams[print].player_array[4]);
    			//printf("%d\n", ID5);
    			printf("||Player6ID: %d \n", teams[print].player_array[5]);
    			//printf("%d\n", ID6);
    			printf("||Player7ID: %d \n", teams[print].player_array[6]);
    			//printf("%d\n", ID7);
    			printf("||Player8ID: %d \n", teams[print].player_array[7]);
    			//printf("%d\n", ID8);
    			printf("||Player9ID: %d \n", teams[print].player_array[8]);
    			//printf("%d\n", ID9);
    			printf("||Player10ID: %d \n", teams[print].player_array[9]);
    			//printf("%d\n", ID10);
    			printf("||Player11ID: %d \n", teams[print].player_array[10]);
    			//printf("%d\n", ID11);
    			printf("||________________________________________________\n");
    		}
    	}
    }
    any ideas? Do I have to use pointers?

    Cheers,

    Submeg.
    Last edited by Submeg; 06-25-2006 at 11:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Help on making program run more efficiently
    By peeweearies in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 02:01 AM
  3. Making a program take a variable number of arguments
    By subtled in forum C Programming
    Replies: 1
    Last Post: 04-17-2007, 05:38 AM
  4. Making interest rate program in C
    By canadas321 in forum C Programming
    Replies: 6
    Last Post: 06-23-2005, 11:59 AM