www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/14/10:58:54

From: "Florent" <florent AT oih DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: checking int
Date: Tue, 14 Mar 2000 14:44:52 +0100
Organization: Aachen University of Technology (RWTH)
Lines: 39
Message-ID: <8alfpb$fle$1@nets3.rz.RWTH-Aachen.DE>
NNTP-Posting-Host: pupulse.oih.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 953041515 16046 137.226.149.42 (14 Mar 2000 13:45:15 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 14 Mar 2000 13:45:15 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,
I don't find the way to check if the input I give to the function scanf is
an int or a char. For example you ask to enter an int, and if a char is
entered -> BUG, so I need something to check if tne input is an int.
It's easy to check if it's a char, but int .... I didn't find.

I wrote this function but it doesnt work, can you help me .....

int input_one_int(char CHAINEval[],int MAXval,int MINval)// Rmq: Bug if char
entered
{

int test=0,check=0,value;

do
   {
    printf("\r%s : ",CHAINEval);
    fflush(stdout);
    fflush(stdin);
    test=scanf("%d*[^\n]",&value);
    if (test==EOF)
       {
       printf("syntax error");
       }
    if ((value<=MAXval)&&(value>=MINval)) check=1;
    } while ((test!=1)||(check==0));

return value;




thank for any help ...
}





- Raw text -


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