Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: floating point

  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    floating point

    Dear sir,

    I trying to write a program that request users to input a value. If users given the floating point value it would displays "Error!" message. How can C program detect the floating point value from the users.


    Best regards,

    Xiang

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    India
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There isn't a direct way to find the datatype of a variable in C as in some programming languages using a method like typeof. But that is because you specify the datatype when you declare the variable. If you are accepting an input as a character string and trying to figure out whether the user entered an integer, or a character string, or a floating point number, then you could probably check each charater for if it's a number. for example, if all the charaters are numbers then the user entered an integer. If there was a period and/or an "e" in addition to numbers, then the user entered a floating point number; if the input contained any other character then the user entered a character string.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •