Thread: Help with Input Checking

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    7

    Help with Input Checking

    im writing a currency conversion program. I know its been covered, but my questions werent answered.

    quite frankly Im terrified of you guys cuz of some of the responses I have seen...maybe its just me...but it seems like you folx are not very friendly to the newbies looking for help. but Im desperate for help, so here goes nothing.

    my current project goes like this:

    a simple program that asks for input, checks to make sure it is an actual number, performs conversion, and prints results.


    <<disclaimers>>
    I've pored over the FAQ's, so please do not jump on me about that.

    I'm doing a homework assignment, and DO NOT want anyone write my code. I am paying a fortune to go to school, so I want to learn it for myself. Therefore my intention is to obtain some explanations of a few things...IN ENGLISH...so I can understand how some of this stuff works.

    Im using the following compiler:

    Miracle C version 3.2, by Tadeusz Szocik, download it here

    I have access to the following textbooks:

    C Primer Plus, third edition
    Absolute Beginners guide to programming, second edition

    Im not necessarily looking for the "best" way. Im looking for the simplest way for a total newbie to achieve the desired result.


    here is the code that asks for input:

    Code:
    printf("Enter the amount of US Dollars you want to convert:\n"); 
    
    scanf("%f",&usd);
    I know that scanf is not necessarily the best way to get the input...thats not my question.

    My question:

    I want to use an IF to check if the input is a number....


    something like this (psuedocode):

    if usd = number, print conversion values
    else print "put in a number, dummy!" and go back to input request.


    thats it. thats all I want to do, but im not sure how the syntax would go.

    I have the currency conversion compiling and executing perfectly...except for checking to see if the input is a number or not. I would be happy to include the rest of the code if it would help.

    again, im not looking for someone to do my work for me. but I dont understand how to write this small part. maybe its a mental block or something, but I dont get it.

    if you read this and can help me out, thanks in advance.
    Last edited by Derek; 06-16-2003 at 12:56 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  2. Checking input
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 05-26-2002, 03:06 AM
  3. Checking input
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-10-2002, 09:00 AM
  4. checking if input is a number ?
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 12-06-2001, 09:07 PM