473,508 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to hide characters on screen

Hi,
Can someone guide me as to how I can modify the code below to hide
characters from displaying on the screen as they are entered? If there is
a better way of achieving this, please let me know.

I'm running this on unix (Solaris8).

thanks.

#include <stdio.h>

int main(void)
{
int passwdstr;

printf ( "Enter password: ");
while ( ( passwdstr=getchar() ) != '\r' ) {
putchar ('*');
}
return 0;
}

Nov 14 '05 #1
2 4918
torno wrote:

Can someone guide me as to how I can modify the code below to hide
characters from displaying on the screen as they are entered?
If there is a better way of achieving this, please let me know.

I'm running this on unix (Solaris8).

#include <stdio.h>

int main(void) {
int passwdstr;

printf ( "Enter password: ");
while ( ( passwdstr=getchar() ) != '\r' ) {
putchar ('*');
}
return 0;
} cat main.c #include <unistd.h>
#include <stdio.h>

int main(int argc, char* argv[]) {
char *getpass(const char* prompt);
fprintf(stdout, "password = %s\n",
getpass("Enter password: "));
return 0;
}
gcc -Wall -std=c99 -pedantic -o main main.c
./main

Enter password:
password = password
Nov 14 '05 #2
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
torno wrote:
Can someone guide me as to how I can modify the code below to hide
characters from displaying on the screen as they are entered?
If there is a better way of achieving this, please let me know.
Read the FAQ. The FAQ is your friend.
<http://www.eskimo.com/~scs/C-faq/q19.1.html>. Admittedly, the way this
question is phrased in the index for section 19 is incomplete; but a
search of the text version (posted here regularly) on "password"
would've turned up this question.
> cat main.c #include <unistd.h>


This is not ISO C, and therefore off-topic.
char *getpass(const char* prompt);
This is not ISO C, and therefore off-topic. Moreover, function
declarations within other functions (yes, even within main()) are a Bad
Thing.
getpass("Enter password: "));


This is not ISO C, and therefore off-topic.
> gcc -Wall -std=c99 -pedantic -o main main.c


We don't care what your broken compiler says, it's still off-topic.

I'd tell you to read the bloody FAQ, as well, but in your case it would
probably be a waste of time, since you don't appear to give a damn.

Richard
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8529
by: jeff | last post by:
Hello, I am coding a web application to be used on an internal Intranet. I have already coded a menubar for the application using DHTML. I want to get rid of the standard menubar in Mozilla...
3
2371
by: Steve | last post by:
I am new to .Net and Visual Studio, I have a login form and my main application form. When I login I want to call the application form, and dispose of the login. I have tried doing something...
5
4475
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
5
1541
by: jrefactors | last post by:
I am trying to debug some values in production server. I want to print the value of rRes(10), but I don't want to show it in the screen. I just want to show it in the source code but comment out,...
1
3067
by: FMorales | last post by:
Hello, we want to do a form on full screen using FormBorderStyle set to FixedToolWindow and, in the form load, seting the FormWindowState property to Maximized and seting TopMost equal to True but...
4
4370
by: Blaine | last post by:
Does anyone know how I can hide a form from the TaskManager? I've set the ShowInTaskbar to False, but when using Alt-TAB to switch between applications, it appears as a blank icon. I can set it...
4
1547
by: BrianDH | last post by:
Hi I have an application with 3 windows forms. One of which I load at startup but hide, then show/hide based on users click. How can I test to see if the windows is hidden, or is at the moment...
0
1271
by: Robert Hilkene | last post by:
Hi there I want to hide output characters in my py program. I found that for Macintosh you implement 4.12 quietconsole -- non-visible stdout output...
6
3202
by: Doogie | last post by:
Hi I have an img control I am trying to hide upon certain types of commands in my code behind. When to hide it is directly tied to a asp:dropdownlist control. So depending on what the user...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.