From: "Donn Mielcarek" Newsgroups: comp.os.msdos.djgpp Subject: Re: Scanf function Date: Mon, 20 Oct 1997 13:38:40 -0400 Organization: Systems Research Labs Lines: 38 Message-ID: <62g4u9$4vv$1@news1.radix.net> References: <62fp85$nq4$1 AT power DOT ci DOT uv DOT es> NNTP-Posting-Host: donn.srl.radix.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Marsel wrote in message <62fp85$nq4$1 AT power DOT ci DOT uv DOT es>... > Hi djgpp users, > > I have writen this code > >#include >main() >{ > char c; > int n; > printf("Write an integer: "); > scanf("%d",&n); > printf("Write a character: "); > scanf("%c",&c); > printf ("The integer is: %d and the character is: %d \n",n,c); > } > >Why the secong scanf function does not wait until the caracter is introduced >?. the c variable always contain the caracter \010 This one always gets new C programmers. When you typed in the integer, you probably also pressed the return key (i.e. newline). You need to take care of reading that. Another scanf in there will do it: int newline; scanf("%d",&n); scanf("%c",&newline); etc... ---------------------------------------------------------------------- Donn Mielcarek donn AT srl DOT radix DOT net ----------------------------------------------------------------------