473,569 Members | 2,879 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=getch ar() ) != '\r' ) {
putchar ('*');
}
return 0;
}

Nov 14 '05 #1
2 4924
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=getch ar() ) != '\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
8538
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 to: a) Stop people getting confused with 2 menubars b) Free up a bit of more screen space
3
2379
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 like: This.Hide myAppfrm.Show(); but then when I close down the myAppfrm, the system hangs as the login screen is still floating about in memory. ...
5
4488
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 functions I have 2 sub functions under each("Add Job", "View Jobs" and "Add User", "View Users"). I have theses subfunctions grouped in a...
5
1543
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, so that I can look at the value. Is it possible? Response.Write("rRes(10) = " & rRes(10)) will show the value in the screen, but i want to hide it...
1
3096
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 .... how can we do that the form were over the main windows bar too??? does it possible to hide or disable it while a run the applicacion that...
4
4379
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 as a SizableToolWindow, but then I no longer have the minimize button on the caption. Is there a way to mimic a (FormBorder) sizable tool window...
4
1550
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 being shown? Thanks BrianDH
0
1276
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 (http://www.python.org/doc/2.0.1/mac/module-quietconsole.html) Can you help me, how I can hide output characters on Windows? Best Regards
6
3203
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 selects in that dropdownlist, this image will be hidden or be displayed. I have tied the onselectedindexchanged value of the dropdownlist to a c-sharp...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
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 we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.