Mail Archives: djgpp/1997/02/17/23:50:02
From: | mceeras AT akula DOT com (Enemy Mindz)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | GETCHE() Command Error using DJGPP?
|
Date: | Mon, 17 Feb 1997 22:48:24 GMT
|
Organization: | Akula Communications Corp.
|
Lines: | 48
|
Message-ID: | <3308e01a.2752561@news.akula.com>
|
NNTP-Posting-Host: | dialup-08.pr1.akula.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Can someone please help me with the following program? The program is
supposed to ask you for two character inputs using the getche()
command. It is supposed to echo the character back as soon as you
type it then determine which of the two characters is greater of the
two.
#include<stdio.h>
#include<conio.h>
void main()
{
char a, b;
printf("Which character is greater?");
printf("\nType a single character:");
a=getche();
printf("\nType another character:");
b=getche();
if(a>b)
{
printf("\n'%c' is greater than '%c'!\n",a,b);
}
else
{
printf("\nNext time, don't type the same character
twice.");
}
}
However when I run this program using DJGPP Compiler, I get the "Which
character is greater?" statement then it seems like it skips the "Type
a single character" statement and pauses. Then when I press a key (in
this case the 'A' key) the following occurs:
AType a single character
Next time dont type the same character.
The program is supposed to prompt me first with the "Type a single
character" then when I type a character for both getche statements I
am supposed to see which letter has a higher value?
However it does not indicate the greater of the two, and the getche()
command is executing before the printf statement.
Can someone help? Thank you.. If you can help please e-mail me at
mceeras AT akula DOT com
- Raw text -