summaryrefslogtreecommitdiffstats
path: root/mbbsd/guess.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-29 03:35:29 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-29 03:35:29 +0800
commit747db9b7bed623d2d957aa14dbc6a505cf763be8 (patch)
tree479cf6940e240c6e6e2f8435e13d97f9269788c5 /mbbsd/guess.c
parent980b8d2d2504b7299ceee845aff46c1f593e498f (diff)
downloadpttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar.gz
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar.bz2
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar.lz
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar.xz
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.tar.zst
pttbbs-747db9b7bed623d2d957aa14dbc6a505cf763be8.zip
change getdata() constant to sizeof()
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@131 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/guess.c')
-rw-r--r--mbbsd/guess.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/mbbsd/guess.c b/mbbsd/guess.c
index 27a337f7..c24b8361 100644
--- a/mbbsd/guess.c
+++ b/mbbsd/guess.c
@@ -1,4 +1,4 @@
-/* $Id: guess.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: guess.c,v 1.2 2002/04/28 19:35:29 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -84,7 +84,7 @@ static int check_data(char *str) {
static char *get_data(int count) {
static char data[5];
while(1) {
- getdata(6, 0, "輸入四位數字(不重複): ", data, 5, LCECHO);
+ getdata(6, 0, "輸入四位數字(不重複): ", data, sizeof(data), LCECHO);
if(check_data(data) == 1)
break;
}
@@ -209,7 +209,7 @@ int guess_main() {
unsigned long int money;
char computerwin = 0,youwin = 0;
int count = 0,c_count = 0;
- char ifcomputer;
+ char ifcomputer[2];
char answer[5];
int *n = NULL;
char yournum[5];
@@ -239,18 +239,19 @@ int guess_main() {
clrtoeol();
prints("您下注 :%d Ptt$", money);
- getdata_str(4, 0, "您要和電腦比賽嗎? <y/n>[y]:", &ifcomputer, 2,
- LCECHO, "y");
- if(ifcomputer == 'y') {
- ifcomputer = 1;
+ getdata_str(4, 0, "您要和電腦比賽嗎? <y/n>[y]:",
+ ifcomputer, sizeof(ifcomputer), LCECHO, "y");
+ if(ifcomputer[0] == 'y') {
+ ifcomputer[0] = 1;
show_table(TABLE, 1);
} else {
- ifcomputer = 0;
+ ifcomputer[0] = 0;
show_table(TABLE, 0);
}
- if(ifcomputer) {
+ if(ifcomputer[0]) {
do {
- getdata(5, 0, "請輸入您要讓電腦猜的數字: ", yournum, 5, LCECHO);
+ getdata(5, 0, "請輸入您要讓電腦猜的數字: ",
+ yournum, sizeof(yournum), LCECHO);
} while(!legal(atoi(yournum)));
move(8, 25);
prints("電腦猜");
@@ -260,9 +261,9 @@ int guess_main() {
}
move(8, 55);
prints("你猜");
- while(((!computerwin || !youwin) && count <10 && (ifcomputer)) ||
- (!ifcomputer && count < 10 && !youwin)) {
- if(!computerwin && ifcomputer) {
+ while(((!computerwin || !youwin) && count <10 && (ifcomputer[0])) ||
+ (!ifcomputer[0] && count < 10 && !youwin)) {
+ if(!computerwin && ifcomputer[0]) {
++c_count;
if(computer(atoi(yournum), c_count, flag, n))
computerwin = 1;
@@ -276,7 +277,7 @@ int guess_main() {
}
}
move(17, 35);
- if(ifcomputer) {
+ if(ifcomputer[0]) {
free(flag);
free(n);
if(count > c_count) {