A89: C problem...
[Prev][Next][Index][Thread]
A89: C problem...
I'm gaving a problem with my C program (problamatic code is below). I'm
working on the highscore and I decided to allow the user to put his/her
initials in. The program displays the initials while the user is typing them
in, but then when you play it the second time it's supposed to show you who
has the highscore and what their initials are, but it only displays their
first initial. I consulted another C programmer for the 89 ,and we
re-arranged and re-wrote the code in different ways (including changing it
from a char variable to an int variable which it is now), but the bug(?) is
still there. Can anyone figure this out? Thanks a lot.
Josh
<A HREF="http://pa.ticalc.org">Programmers Anonymous</A> Member
void end(int score,int *highscore,int *initials)
{
int count,key=0,x=0;
clrscr();
printf("Game Over");
printf("\nYour score is %d.",score);
if(score<=*highscore)
printf("\nHighscore is %d by %c",*highscore,*initials);
if(score>*highscore)
{
printf("\nOld High Score was %d",*highscore);
*highscore=score;
printf("\nNew High Score of %d!",score);
printf("\nEnter your initials.\n");
for(count=0;count<=2;count++)
{
GKeyFlush();
while(key==0)
{
key=getchar();
ST_busy(ST_IDLE);
}
*initials=key;
initials++;
key=0;
}
}
GKeyFlush();
GKeyIn(NULL,0);
clrscr();
return;
}
//...more code here...
//in _main
static int initials[3]={0,0,0,NULL};
//...rest of program
Follow-Ups: