From: "Jason" Newsgroups: comp.os.msdos.djgpp Subject: Urgent ! Please help!!! Date: Tue, 18 Jan 2000 14:41:35 +0800 Organization: netteens.net (Hongkong Telecom IMS) Lines: 238 Message-ID: <861210$4tj$1@imsp026.netvigator.com> NNTP-Posting-Host: olkc10a202.netvigator.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000A_01BF61C2.1E6D6A20" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.3825.400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.3825.400 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_000A_01BF61C2.1E6D6A20 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi everybody! Can anyone tells me what's wrong if I change my porg from = version 1 to version 2? (note: NUM_LPAYERS=3D2) Version 1: void get_name(char Player1[], char Player2[], PLAYER player_array[], int = curplays[]) { char P1[5]; =20 char P2[5]; =20 char sp[] =3D " "; =20 char a; int level; clrscr(); list_players(player_array); =20 printf("\n\n Please choose who is to play as player 1 (choose 1 thru = %d) :", NUM_PLAYERS); gets(P1); while ((P1[0]<'1') || (P1[0]>NUM_PLAYERS+'0')) =20 { printf("%c is invalid, please rechoose: ",P1[0]); gets(P1); } /*changes starts here*/ printf("\n\n Please choose who is to play as player 2 (choose 1 thru = %d, except %c) :", NUM_PLAYERS, P1[0]); gets(P2); while (((P2[0]<'1') || (P2[0]>NUM_PLAYERS+'0')) || (P2[0]=3D=3DP1[0])) = =20 { printf("%c is invalid, please rechoose: ",P2[0]); gets(P2); } /*changes ends here*/ curplays[0]=3D (int) (P1[0] - '1'); =20 curplays[1]=3D (int) (P2[0] - '1'); =20 strcpy(Player1, player_array[(int) (P1[0] - '1')].first); =20 strcat(Player1, sp); strcat(Player1, player_array[(int) (P1[0] - '1')].last); strcpy(Player2, player_array[(int) (P2[0] - '1')].first); =20 strcat(Player2, sp); strcat(Player2, player_array[(int) (P2[0] - '1')].last); =20 return; } Version 2: void get_name(char Player1[], char Player2[], PLAYER player_array[], int = curplays[]) { char P1[5];=20 char P2[5]; =20 char sp[] =3D " "; =20 clrscr(); list_players(player_array); =20 printf("\n\n Please choose who is to play as player 1 (choose 1 thru = %d) :", NUM_PLAYERS); gets(P1); while ((P1[0]<'1') || (P1[0]>NUM_PLAYERS+'0')) =20 { printf("%c is invalid, please rechoose: ",P1[0]); gets(P1); } /*changes starts here*/ =20 if (P1[0]=3D=3D'1') P2[0]=3D'0'; else if (P1[0]=3D=3D'0') P2[0]=3D1; /*changes ends here*/ =20 curplays[0]=3D (int) (P1[0] - '1'); =20 curplays[1]=3D (int) (P2[0] - '1'); =20 strcpy(Player1, player_array[(int) (P1[0] - '1')].first); =20 strcat(Player1, sp); strcat(Player1, player_array[(int) (P1[0] - '1')].last); strcpy(Player2, player_array[(int) (P2[0] - '1')].first); =20 strcat(Player2, sp); strcat(Player2, player_array[(int) (P2[0] - '1')].last); =20 return; } ------=_NextPart_000_000A_01BF61C2.1E6D6A20 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
Hi everybody! Can anyone tells me = what's wrong if I=20 change my porg from version 1 to version 2?
(note: NUM_LPAYERS=3D2)
 
Version 1:
void get_name(char Player1[], char = Player2[],=20 PLAYER player_array[], int curplays[])
{
 char=20 P1[5];           &= nbsp;           &n= bsp;          
 char=20 P2[5];           &= nbsp;           &n= bsp;          
 = ;char=20 sp[] =3D "=20 ";            = ;            =      
 char a;
 int=20 level;
 clrscr();
 =20  list_players(player_array);      &nbs= p;          =20
 
 printf("\n\n Please choose who is = to play as=20 player 1 (choose 1 thru %d) :", = NUM_PLAYERS);
 gets(P1);
 while=20 ((P1[0]<'1') ||=20 (P1[0]>NUM_PLAYERS+'0'))       &nbs= p;   
  =20 {
    printf("%c is invalid, please rechoose:=20 ",P1[0]);
   gets(P1);
   }
 
/*changes starts = here*/
 printf("\n\n Please choose who is = to play as=20 player 2 (choose 1 thru %d, except %c) :", NUM_PLAYERS,=20 P1[0]);
 gets(P2);
 while (((P2[0]<'1') ||=20 (P2[0]>NUM_PLAYERS+'0')) || = (P2[0]=3D=3DP1[0]))   
   {
   =  printf("%c is=20 invalid, please rechoose: = ",P2[0]);
  gets(P2);
  =20 }
/*changes ends=20 here*/

 curplays[0]=3D (int) (P1[0] - = '1');           &n= bsp;           &nb= sp;    
 curplays[1]=3D=20 (int) (P2[0] -=20 '1');           &n= bsp;           &nb= sp;    
  =20 strcpy(Player1, player_array[(int) (P1[0] -=20 '1')].first);    
   strcat(Player1,=20 sp);
   strcat(Player1, player_array[(int) (P1[0] -=20 '1')].last);
   strcpy(Player2, player_array[(int) (P2[0] - = '1')].first);    
   strcat(Player2,=20 sp);
   strcat(Player2, player_array[(int) (P2[0] -=20 '1')].last);    
return;
}
Version 2:
void get_name(char Player1[], char = Player2[],=20 PLAYER player_array[], int curplays[])
{
 char=20 P1[5]; 
 char=20 P2[5];           &= nbsp;           &n= bsp;          
 = ;char=20 sp[] =3D "=20 ";            = ;            =      
 clrscr();
 =20  list_players(player_array);      &nbs= p;          =20
 
 printf("\n\n Please choose who is = to play as=20 player 1 (choose 1 thru %d) :", = NUM_PLAYERS);
 gets(P1);
 while=20 ((P1[0]<'1') ||=20 (P1[0]>NUM_PLAYERS+'0'))       &nbs= p;
  =20 {
    printf("%c is invalid, please rechoose:=20 ",P1[0]);
  gets(P1);
   }
 
/*changes starts=20 here*/  
   if = (P1[0]=3D=3D'1')
  =20 P2[0]=3D'0';
   else if (P1[0]=3D=3D'0')
   = P2[0]=3D1;
/*changes ends=20 here*/
   
 curplays[0]=3D (int) = (P1[0] -=20 '1');           &n= bsp;           &nb= sp;    
 curplays[1]=3D (int) (P2[0] -=20 '1');           &n= bsp;           &nb= sp;    
  =20 strcpy(Player1, player_array[(int) (P1[0] -=20 '1')].first);    
   strcat(Player1,=20 sp);
   strcat(Player1, player_array[(int) (P1[0] -=20 '1')].last);
   strcpy(Player2, player_array[(int) (P2[0] - = '1')].first);    
   strcat(Player2, = sp);
  =20 strcat(Player2, player_array[(int) (P2[0] - = '1')].last);    =20
 return;
}
------=_NextPart_000_000A_01BF61C2.1E6D6A20--