I want to write a program that takes as an input a string and returns an encoded string. An encoded string would be string where each of the characters present in the original string are shifted by a few fixed number of places. Eg. Suppose each character in a string is shifted by 2 places. So if the user enters 'abcd' the output will be 'cdef'.
I am able to do it by taking the whole string as input and then processing each character to give the final output string.
But what I want is that as soon as the user enters a character, it should be shown in its encoded form and not its original form.
I tried the following code for a single character.
char r;
scanf("%c",&r);
printf("\b%c",r+2);
But the user is still able to see he character he entered. The encoded character doesn't appear unless I press 'Enter'. How can I rectify this? Maybe using another function to get the character? Any help appreciated.