Do not get confused by the title of the Article. I am here to give you a simple program that would take the Input from you, Then, what is the big deal here ? The point is that you are not allowed to print anything of the input on the Input Window, I mean you can diplay an *, a # or a @, but you can’t show the entered Password String.
Ok, It is a bit confusing, let me tell you, suppose you enter something like “Computer”. In C, the input is not sent to Processor until you press Enter Key on your mighty Key Board, until then, All the input characters on the wisible on the Run Screen. So, Now the task is simpler, you are REQUIRED to accept the input on the Run Window but you are not allowed to display the entered characters on the Run Window before the user hits Enter. So, lets see, how it can be done ?
If you have some prograaming on TCC (Turbo C++) compiler, I am sure that you must have used getch() command. At that time, you are told that this function would hold your Run Window until you press Enter and since, you can not exit the Run Window until you press the Enter key, you are able to see what you have done with your prograaming.
Actully, the fact is somewhat different, getch() does not works as we think it does, it is one of the input functions available to the C Programmer. It is a single special Input type pre defined function that takes input but does not displays anything on the Screen. So, the task is more simpler now. But this also leads to another confusion, if it is so, then why it helps in Stopping the Otput window. The reason in more simple. It takes an input and returns the chatacer, so, the program”s last instruction is to take an imput from the user and then exiting the program. You can see its syntax in the Help Section available in TC++.
I am probiding you the program, how I did it.
# include<conio.h> # include<stdio.h> int main() { char a[20]; int i,j; for(i=0;i<20;i++) { a[i]=getch(); if(a[i]==13) break; else printf("*"); } printf("\n"); for(j=0;j<i;j++) printf("%c",a[j]); return 0; }
The program is quite simpler, However, I have left something here. If you make a typo, this program would not correct it, you displayed passowrd would be entirely differebt than you wanted to enter. The reason is that I have not included any special action to be taken if it encounters a backspace key. However, I have mentioned the action to be taken if it encounters Enter Key. I have not included that section here, you can do it by yourself by little knowledge of ASCII, array and LOGIC. If you fail to do that,just ping me here by commenting here, I will mail you the complete program.
Good Luck, 🙂
Melaka state government plans to develop a system to guide the tourists to go to the nearest tourism destination spot. The system asks for password before the user is able to use the system. The system allows for 3 times of password entry attempts. If all 3 attempts are failed, the system will be terminated. However, after successful login, the system will ask user’s current location and their preferred destination spot. The user may select one or more destination, but only the nearest one will be suggested to the user, and the cost of transportation to go to the suggested destination is given. You are, as the developers of the system, must follow the requirements described below. However, you are free to add your own functions, variables, or et cetera.
Looks like someone wants to give me a homework.
Well, I am ready sir.
Just, it is not the place to ask for it.
Ping me on gaurav@mycfiles.com
We will talk about it.
GoodLuck. 🙂