The console shows then disappear before I can see the result when I enter an invalid character. See the code below Also I had to use cin.get() in all functions except the main, is this a normal practise? If I don't enter 'e' or 'E', I must have entered 'D'? What you probably mean is: conversion Type equals 'E' OR conversion Type equals 'e' The last call is not a call at all, it's a function declaration.C doesn't allow function declarations inside functions, but the g compiler (that you use too with Dev-c ) does allow them.I asked a few days ago about integer input validation functions and I got that working, but it appears letters act a bit different? My guess is you have a trailing newline characterfrom some previous input function. It is hard to tell without seeing more code, like where in your program you called this function.I suspect you're having a problem with a "scanf()" somewhere, but it's difficult to say without seeing more code. I ran this function from a simple program and it appears to be doing what you want.Basically this function checks if the user input 1) a valid letter character, and 2) the user enters either A or P, and this is case-sensitive.When I test this function, I enter in A or P as it asks "Enter a letter (A or P)".I'm trying to validate user input that user must enter number and it must be greater than 0, the validation of only numbers I got it working; however, I can't seem to incorporate the validation of greater than 0 I think that should fix it. I don't know what you had going on in that while condition. Zexanima's version because he's using the assignment operator ('=') instead of the comparator ('==') (or in the case: unequality comparator '!
These supplies and returns of information to a computer are called input and output.Hello, I wrote this code to convert from dollars to euro and vice versa, it takes the user input "char" character to indicate the currency that needs to be converted and the amount.Problem I have is that I cant seem to validate the 'char' input, I tried some validation type but it did not work I thought the switch statement should take care of that. Lastly i know the code is cubersome, I just wanted to practise defining functions with parameters and referencing them form main function. First, the else part is just plain wrong don't you think? Your test gets interpreted as follows: conversion Type equals 'E' OR 'e' This is always true.Different things such as on every 2nd enter it shows the prompt to enter correct letter.And then when I enter either A or P it finally recognizes the letter and then ends the program.