1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

scanf - turbo c/c++

Discussion in 'C++' started by gatsbycollege, Jan 9, 2012.

  1. gatsbycollege

    gatsbycollege New Member

    Joined:
    Dec 27, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Philippines
    Code:
    #include <conio.h>
    #include <stdio.h>
    
    main()
    {
    int a;
    printf ("Enter Number ");
    scanf ("%d",&a);
    printf ("Num is %d",a);
    getch();
    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,,
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page