Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   scanf - turbo c/c++ (http://www.go4expert.com/forums/scanf-turbo-c-cpp-t27567/)

gatsbycollege 9Jan2012 21:47

scanf - turbo c/c++

#include <conio.h>
#include <stdio.h>

int a;
printf ("Enter Number ");
scanf ("%d",&a);
printf ("Num is %d",a);
return 0;

my problem is that my prof want me to disable inputing of dot (".") when I input data in scanf, somebody know how to do it?
i think of having if statements if (a=='.') b=8;printf ("%c",b);
where i want to set decimal 8 to ascii which is backspace; but it only execute when i enter during the scan,,

xpi0t0s 10Jan2012 05:04

Re: scanf - turbo c/c++
Use fgets to read a line of input from the user (use stdin as the file pointer). Then you can parse the input to your heart's content.

All times are GMT +5.5. The time now is 02:17.