dimanche 1 mars 2015

How to use scanf to read a value without knowing its type [on hold]



I'm a beginner student. I was asked to write a module that translates user input based on the following rule:




  • if character is a letter make it upper case




  • if character is a number make it * instead




  • if character is a \, the next character will be unaffected




The program must continue to call scanf() to read characters from the user until EOF is encountered.Note: You should be printing characters as soon as you get them. Do not attempt to save them.


Example:



input : Hi Mike your room number is \4\2\3 and the passcode is 312
output: HI MIKE YOUR ROOM NUMBER IS 423 AND THE PASSCODE is ***


Now my question is: since you don't know what type of character will be entered next, how can you save it in a varaible like scanf("%c", &func) saves the character in func? Also I'm not allowed to use toupper() so how can I make a letter upper case?


Any help is appreciated!!Thanks




Aucun commentaire:

Enregistrer un commentaire