Mail Archives: djgpp/1996/08/31/14:49:59
Xref: | news2.mv.net comp.os.msdos.djgpp:8103
|
From: | "Bob Platko" <platko AT ix DOT netcom DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Scanf doesn't work
|
Date: | 31 Aug 1996 14:38:49 GMT
|
Organization: | Netcom
|
Lines: | 64
|
Message-ID: | <01bb974a$24b5f820$24c5b7c7@platko.ix.netcom.com>
|
NNTP-Posting-Host: | clv-oh1-04.ix.netcom.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Anyone been having problems with scanf?
When using multiple scanf's in a program, only the input from the last
scanf is saved
in the varible.
My code works fine in Borland, but not in DJGPP! What's wrong?
---Code---
#include <stdio.h>
#include <stdlib.h>
void main (void)
{
unsigned short i;
unsigned short k,l;
unsigned short j;
unsigned short remainder;
unsigned long num_of_prime_numbers=0;
signed char placeholder;
printf("Enter the range of the prime numbers\n");
scanf("%u",&k);
scanf("%u",&j); /*In DJGPP, only 'j' is stored. 'k' is zero? */
printf("Prime numbers between %d ",k);
printf("and %d.",j);
for(i=k; i<j; i++)
{
placeholder=-1;
for(l=2; l<i; l++)
{
remainder = i % l;
if(remainder == 0)
{
placeholder=0;
break;
}
}
if(placeholder==-1)
{
printf("%d,",i);
num_of_prime_numbers++;
}
}
printf("\n\n\nTotal number of prime numbers in range:
%ld",num_of_prime_numbers);
getch();
}
---End of Code---
- Raw text -