delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/18/17:22:55

From: "Jason" <manman AT netteens DOT net>
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
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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 5.50.3825.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi everybody! Can anyone tells me =
what's wrong if I=20
change my porg from version 1 to version 2?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(note: NUM_LPAYERS=3D2)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Version 1:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>void get_name(char Player1[], char =
Player2[],=20
PLAYER player_array[], int curplays[])<BR>{<BR>&nbsp;char=20
P1[5];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</DIV></F=
ONT>
<DIV><FONT face=3DArial size=3D2>&nbsp;char=20
P2[5];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp=
;char=20
sp[] =3D "=20
";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;char a;<BR>&nbsp;int=20
level;<BR>&nbsp;clrscr();<BR>&nbsp;=20
&nbsp;list_players(player_array);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2>&nbsp;</DIV></FONT>
<DIV><FONT face=3DArial size=3D2>&nbsp;printf("\n\n Please choose who is =
to play as=20
player 1 (choose 1 thru %d) :", =
NUM_PLAYERS);<BR>&nbsp;gets(P1);<BR>&nbsp;while=20
((P1[0]&lt;'1') ||=20
(P1[0]&gt;NUM_PLAYERS+'0'))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp; &nbsp;printf("%c is invalid, please rechoose:=20
",P1[0]);<BR>&nbsp;&nbsp;&nbsp;gets(P1);<BR>&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>/*changes starts =
here*/</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;printf("\n\n Please choose who is =
to play as=20
player 2 (choose 1 thru %d, except %c) :", NUM_PLAYERS,=20
P1[0]);<BR>&nbsp;gets(P2);<BR>&nbsp;while (((P2[0]&lt;'1') ||=20
(P2[0]&gt;NUM_PLAYERS+'0')) || =
(P2[0]=3D=3DP1[0]))&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; {<BR>&nbsp;&nbsp; =
&nbsp;printf("%c is=20
invalid, please rechoose: =
",P2[0]);<BR>&nbsp;&nbsp;gets(P2);<BR>&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>/*changes ends=20
here*/</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;curplays[0]=3D (int) (P1[0] - =

'1');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;curplays[1]=3D=20
(int) (P2[0] -=20
'1');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;=20
strcpy(Player1, player_array[(int) (P1[0] -=20
'1')].first);&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp; strcat(Player1,=20
sp);<BR>&nbsp;&nbsp; strcat(Player1, player_array[(int) (P1[0] -=20
'1')].last);<BR>&nbsp;&nbsp; strcpy(Player2, player_array[(int) (P2[0] - =

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

'1')].first);&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; strcat(Player2, =
sp);<BR>&nbsp;&nbsp;=20
strcat(Player2, player_array[(int) (P2[0] - =
'1')].last);&nbsp;&nbsp;&nbsp;&nbsp;=20
</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;return;<BR>}<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_000A_01BF61C2.1E6D6A20--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019