Xref: news2.mv.net comp.os.msdos.djgpp:8121 From: "Luis A. Salazar" Newsgroups: comp.os.msdos.djgpp Subject: Re: Scanf doesn't work Date: Sat, 31 Aug 1996 16:46:17 -0500 Organization: The University of Texas at San Antonio Lines: 31 Message-ID: References: <01bb974a$24b5f820$24c5b7c7 AT platko DOT ix DOT netcom DOT com> NNTP-Posting-Host: lonestar.jpl.utsa.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <01bb974a$24b5f820$24c5b7c7@platko.ix.netcom.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On 31 Aug 1996, Bob Platko wrote: > 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? > The formatting code that is used when reading an unsigned short with scanf is %hu. When printing an unsigned short with printf you should use %u. The foregoing can best be exemplified with the following short program: #include main() { unsigned short k, j; printf("Enter two numbers"); scanf("%hu", &k); scanf("%hu", &j); printf("\n\n"); printf("%u\n%u", k, j); return 0; }