From 47aa926523131ca59a64c6342b37c563d6a942f0 Mon Sep 17 00:00:00 2001 From: Amitha Perera Date: Tue, 25 Nov 2008 09:52:21 -0500 Subject: [PATCH] BUG: the return value of scanf should not be ignored --- Templates/TestDriver.cxx.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 41fccaeb1..8c9f54efe 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -70,7 +70,11 @@ int main(int ac, char *av[]) printf("To run a test, enter the test number: "); fflush(stdout); testNum = 0; - scanf("%d", &testNum); + if( scanf("%d", &testNum) != 1 ) + { + printf("Couldn't parse that input as a number\n"); + return -1; + } if (testNum >= NumTests) { printf("%3d is an invalid test number.\n", testNum);