Validating input in c

Once they select the number, 1 for Euro, 2 for Deutsche Mark etc, it will prompt you for how many US dollars you want to convert to your selected currency.After entering a dollar number 0, it will do the conversion and display it for you.I have been unsuccessful in doing this so I decided to start over. If any further information is needed please let me know. the input value should be tested after the scanf with an if statement this if statement should change the flag to a value that will cause the loop to exit when a valid value is entered or in the else condition print an error message and leave the flag alone (so that the loop will repeat and a new value may be entered). chuck wrote: I need some help with validating user input.

During the step for selecting what currency you want to convert to and when entering the amount of use dollars, they have to be certain data types. If it is anything else they will go thru a loop and be prompted again to give a selection number (1-5). From the C FAQ: 12.26a: How can I flush pending input so that a user's typeahead isn't read at the next prompt? After entering a dollar number 0, it will do the conversion and display it for you. If you're trying to actively discard typed-ahead input (perhaps in anticipation of issuing a critical prompt), you'll have to use a system-specific technique; see questions 19.1 and 19.2. I am writing a C computer program for an intro to C course. I am creating an application that will do currency conversions.The only thing is though that when I enter a 1 to select Euro the app does absolutely nothing. If you allow scientific notation, you will also need to check for 'e', 'E', 'd' and 'D'.Since it is currency, I would suggest that you can assume fixed point format. Reading the currency value into your program as an integer is a bad idea.I have been unsuccessful in doing this so I decided to start over. If any further information is needed please let me know. Look up the isdigit() function, which will tell you if the character you saw was a digit from 0 to 9.The link below has what I have so far and now when I put a character say 'f' when it asks me for a selection number, it asks me again for a selection # (meaning that i inputted a wrong data type). Look up the ispunct() function, which will tell you if the character you saw was punctuation.

Search for validating input in c:

validating input in c-79validating input in c-21validating input in c-31

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating input in c”