www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/19/15:30:12

From: "mike" <mike AT hippies DOT fsnet DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with scanf
Date: Thu, 19 Jul 2001 20:17:00 +0100
Lines: 42
Message-ID: <9j7bsc$ilg$1@newsg4.svr.pol.co.uk>
NNTP-Posting-Host: modem-12.ekkaia.dialup.pol.co.uk
X-Trace: newsg4.svr.pol.co.uk 995570380 19120 62.136.177.12 (19 Jul 2001 19:19:40 GMT)
NNTP-Posting-Date: 19 Jul 2001 19:19:40 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

This is a pretty silly little c program, but it highlights a problem that I
am having with djgpp. This will compile in tc++2.01 and work perfectely.
However, although it compiles okay in djgpp it will not scan with a scanset
after the first scan. (I hope you follow that.)
It will, however, scan without a scanset after the first scanset; this is
not much use to me in the application I am coding.
    I tried using copiler option such as -fwritable-strings this did not
work. I could not try -traditional as it caused problems with the headers.
If anyone could help me with this it would be great.

mike

#include<stdio.h>

main()
{
 char a[25];
    int b,c;

    printf("Please input a number ");
    scanf("%5[0-9]s",a);
    b=(atoi(a));
 printf("b= %d \n",b);
 fflush(stdin);

    printf("Please input a number ");
    scanf("%5[0-9]s",a);
    c=(atoi(a));
 printf("b= %d c= %d ",b,c);
 fflush(stdin);

    printf("Enter some Text ");
 scanf("%5[a-z]s",a);
 printf("b= %d c= %d text= %s ",b,c,a);
 fflush(stdin);
    return(0);
}





- Raw text -


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