Mail Archives: djgpp/1998/04/26/21:16:33
From: | Brad <krusty AT iaccess DOT com DOT au>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Programming Prob.
|
Date: | Sun, 26 Apr 1998 23:38:23 +1000
|
Organization: | Internet Access Australia
|
Lines: | 34
|
Message-ID: | <354338CF.FF6D8CF4@iaccess.com.au>
|
NNTP-Posting-Host: | synport9.iaccess.com.au
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
In the following program, I have to print the largest integer using the
if statement. It works as it is using " else " but I was wondering why I
can't get it to work without the" else ".As I understand it, if I leave
out the else the program should skip " answer = int1 ".It doesn't , that
is why I had to add " else ".If you can help please email at
krusty AT iaccess DOT com DOT au
Thanks in advance
Brad.
#include <stdio.h>
void main(void)
{
int int1,int2,answer;
printf("Please enter 2 integers.\n");
scanf("%i %i",&int1 ,&int2);
if (int1 > int2)
answer = int1;
else
answer = int2;
printf(" The larger integer is %i \n"),answer;
}
The error does not appear to be code-dependant, but the problem arises when
I enter the simple line:
a=(a|b)
I have tried this every which way and cannot get it to work. I have tried
changing the code. I have put the OR function in a macro. I have changed
the keyboard from UK English to US English. Nothing will get it past the
error.
Incidentally, I have since had the opportunity to enter the identical code
on the same machine as a Win32 console application under MSVC5.0 and it
works fine (at least with a UK English keyboard setting, I have not tried
the US setting).
As noted by Thomas Demmer, the problem appears to be one of recognising the
correct character from the keyboard, which is why I tried the US setting.
Any help would be appreciated.
Derek Jackson
- Raw text -