I'm building a very simple calculator program for currency exchange rates where the user selects, with the press of a letter from a list of choices, the currency of an original amount, and then the currency he desires the funds to be converted into.
When using the _getche() function before the if statements, I want the letter that was input to be displayed in uppercase, hence the toupper. My problem is this: the _getche() values do not show as uppercase except on the last two lines of code where the final amount is displayed.
Is this related to my if/else structures or I'm missing something here??
Variables are in french, but I can translate if needed... I don't simply want the answer either, I'm here to learn... Thanks guys!
You could try DeviseInitiale = toupper(_getche());.
I assume that _getche() is capturing the user's input and returning whatever character the user input.
Are you using toupper so that you only need to check for capital letters?
You will only see the character as a capital letter after toupper has been called unless the user entered a capital letter in the first place.
If you want the user to see a capital letter as he/she is entering it, the user will only see a capital letter on the input line if he or she enters a capital letter.
I'm sorry if I didn't quite understand the questions.
If there is an issue with your output, can you provide some sample output?
JayZom, you understood my question perfectly and your answer makes all the sense in the world, that's also how I undestood the attribute would work... But when you say
You will only see the character as a capital letter after toupper has been called unless the user entered a capital letter in the first place.
If you want the user to see a capital letter as he/she is entering it, the user will only see a capital letter on the input line if he or she enters a capital letter.
Is there a way to 'transform' the letter inputed by the user to a capital even before it gets displayed on the screen??
My mistake. I am not familiar with conio.h.
Follow MiiniPaa's links for more info.Unfortunately, we can't do that. Programs that aren't console-based can do that, but that is because other programs use different ways of displaying input. The console can't do that. The user will see whatever they typed into the console, but there isn't any way to transform that.
After the user enters input, you can do whatever you want with that input, though. It would be cool if we could do that, though! But that could introduce security issues, since we would be able to force the console to think the user entered something else.