www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/26/20:03:17

From: "Michael Ahumibe" <M DOT Ahumibe AT btinternet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: is this a bug?
Date: Tue, 27 Mar 2001 01:49:00 +0100
Organization: BT Internet
Lines: 31
Message-ID: <99oo0k$gr7$1@neptunium.btinternet.com>
NNTP-Posting-Host: host213-1-206-165.btinternet.com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi

The following program should ask for a character to be input near the end

#include <stdio.h>

int main()
{
 char string[20];
 unsigned int number;
 char test;

 printf("Enter a string: ");
 scanf("%s", &string);

 printf("Enter a number: ");
 scanf("%u", &number);

 printf("Enter a character: ");
 scanf("%c", &test);


 printf("%s %u %c",string,number,test);

 return 0;
}

I compile the code and run it. The line containing scanf("%c", &test); is
skipt!! can someone tell me the exact reason for this?


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019