Password in c++ | Deleting a character after printing it - c++

When we type password in websites ,we see * or . instead of characters.How can this be made possible with c++.Suppose I am trying to input password through stdin and at the same time I am storing it in a char array and deleting the character input by the user and outputing * instead.I think deleting the character is the trick here.But how do we delete a character after having printed it via stdout.

Read the key with _getch() (header <conio.h>), save/process it, and print '*' character instead of it. <conio.h> is available only on Windows afaik, though.

It depends upon the operating system and relevant libraries (the C++ standard does not define anything related to that).
On Linux, you might use ncurses or readline libraries (on the terminal). And if coding a GUI application, your toolkit (eg Qt) provides a relevant widget.

On this page C++ password in console you can find the answer. They use conio.h library, but in the middle of this page there is a better solution for Windows.

Related

How to take the input while the user is typing in c++

I want to make a program which does autocomplete when a user types in the console window. For that I will maintain a dictionary of words and output some of the words that starts with the same word user is typing. But how do I take the input while the user is still typing on console?
If you are working on Windows platform you can use PDCurses to get your characters one by one using getch(). you can find the documentation link
: PDCurses.txt and here's a tutorial how to set up PDCurses in visual studio.
If you are working on Linux, Unix or OS X you can use NCurses.
Hope this will help.

Which steps are needed for an Unicode program in C++

I want to write a C++ program which can support typing Unicode characters in text editors like LibreOffice, MS Office, Notepad, (because I'm a Vietnamese and my mother tongue language includes Unicode characters such as: đ, â, à ế, ẹ, ẻ, ...). That means when I use a text editor like those above or any applications which can support text editing such as Browsers (in address bar or search bar), Chat applications like Yahoo or Skype, ... and when I type a key or a group of keys in keyboard, my C++ program will notice that and convert it into Unicode character and send it back to text editor.
For example, when I type double 'e' key in text editor, C++ program with notice that and make it as 'ê' in text editor. Please tell me steps needed or mechanism to do a such application. I don't know where to start.
Use a solid library like Qt, wxWidgets, or if you don't need extra ballast, plain old ICU
As far as I understood you want to write an IME (input method editor). There are plenty of them available already for Vietnamese, supporting various input methods.
You did not specify the platform. However for both Windows and Linux there are quite a many Vietnamese IMEs available - practically all are open source for Linux, and Unikey, which to my knowledge is one of the most popular IMEs for Windows, is also an open source program, and thus would provide an easy start for hacking your own favourite options to an IME.

Pseudographical environment in windows Command Prompt

actually i'm thinking of creating a cool interface for my programming assignment , so i go around searching on how to do it so that such an effect can be create , below is the image .
The Question
1.)What is needed in order to create a program that run pseudographic(semigraphic or whatever they called it) that has menu like BIOS wizard did??I always see some program run in console but it could have graphical-like looking , for example blue environment , and user can use keyboard to choose a list of setting in a menu.
Thanks for spending time reading my question.
It's called Text-based user interface. There're several libraries for doing this. I think this is what you're looking for. :)
Cross platform, Interactive text-based interface with command completion
http://www.gnu.org/s/ncurses/
Ncurses(or maybe pdcurses) is probably what you need.
In the days of 16-bit Windows console windows used to support ANSI escape sequences (via the ansi.sys driver), but they no longer do.
For the apparent line graphics you need to use a platform specific solution anyway, so I recommend just writing an abstraction (functions, class) over the Windows APIs console functions.
The line graphics is done by using characters from the original IBM PC character set, codepage 437. At first you can just hardcode the various patterns. In order to make it seem more like line drawing to the code, or from the code's perspective, so to speak, you'll have to abstract things again. As I remember there is some partial but not complete system in the original codepage 437 character codes. But for Windows console you will need to use the Unicode character codes, which probably do not preserve the original system, so perhaps just define a map where these graphics characters are placed more systematically.
Possibly that already exists.
If you don't care about portability, the Windows API for this can be found here. It will supply all the functions you need, without the need to pack additional libraries with your application.
You can also look in to graphics.h, a non-standard Borland extension that a lot of older graphical games used to use. It goes far beyond the normal limits of the console, but is only supported by 16 bit systems, of which Microsoft has all but removed support for from Windows. You'd also need an ancient Borland compiler, or an emulation, though you probably want the original look and feel.

C++ screen partition

I want to partition the output screen into two parts (just like frames do it in HTML). So that one part may remain fixed and display some content which is updated based on input received from the other part.
I do not wish to venture into GUI stuff therefore OpenGL, SDL etc are ruled out (I wish to do it in command line mode). I have Borland C++ with graphics.h support, but it is just too old to carry on.
What alternatives do I have at my disposal (If not C++, a solution in C will also be Ok.)
You may want to take a look at curses-like libraries like PDCurses.
Other than that, you may use ANSI terminal escape sequences to control the cursor on a text window, this may be quicker if what you are doing is simple, otherwise use PDCurses and it will handle the escape sequences for you.
Check out Curses / NCurses.

Invisible input for passwords? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Read a password from std::cin
I want to cin>>input but when they input something i don't want it to be visible to them. Like when you use passwd in unix to change your password where it doesn't show what you typed. i hope it is clear what i am asking. Thank you in advance.
From C++ FAQ Lite
This is not a standard C++ feature — C++ doesn't even require your system to have a keyboard or a screen. That means every operating system and vendor does it somewhat differently.
Please read the documentation that came with your compiler for details on your particular installation.
cin isn't the way to do this, since the OS (usually) echoes standard input. What you need to do is handle the key events at the OS-level.
There is getpass(3) for Unix-like systems, which will do what you want.
However,
It's not portable (Unix systems only).
It's deprecated ("Present in SUSv2, but marked LEGACY. Removed in POSIX.1-2001.").
There is no way to do it with standard C or C++.
If what you want is something like what you do when you enter the password to login to a linux box, that behavior cannot be achieved in C or C++. You will have to use a platform specific library to do that. More specifically, console input in C and C++ is always echoed to the console.
Have it detect key presses. Think of it this way: When a user presses the 'A' key in a video game, the program runs code; don't think of it as receiving input. Think of it as detecting keystrokes and adding each keystroke to some data structure (e.g. an array).
I am familiar with the functionality in UNIX terminal that you are talking about and it doesn't allow you to backspace or anything. If you want that functionality, just do what I said above.
If you want to be able to backspace, although the user won't be able to see what they backspace, you can write code that removes the last element of the array when the user clicks backspace.
Also, everyone else is correct when they say that you will need to program this specific to the system you're running it on.
Lastly, this might not be secure if you are using this for a password and just throwing it into an array.