473,573 Members | 2,902 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to input string as password.

hi everybody,

i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.

Feb 9 '07 #1
14 9451
sriram wrote:
hi everybody,

i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>

int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.

--
Alan Johnson
Feb 9 '07 #2
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.

#include <string>
#include <iostream>

int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;

}

If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.

--
Alan Johnson
yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...

n yr prg wont run as it doesn't return any value as declared in int
main();

Feb 9 '07 #3
sriram wrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
>sriram wrote:
>>hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>

int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;

}

If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.

--
Alan Johnson

yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...
As far as I know what you want to do cannot be done in standard C++.
n yr prg wont run as it doesn't return any value as declared in int
main();
Incorrect.

3.6.1/5:
A return statement in main has the effect of leaving the main
function (destroying any objects with automatic storage duration) and
calling exit with the return value as the argument. If control reaches
the end of main without encountering a return statement, the effect is
that of executing
return 0;
--
Alan Johnson
Feb 9 '07 #4
sriram schrieb:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
>sriram wrote:
>>hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>

int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;

}

If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.

--
Alan Johnson

yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...

n yr prg wont run as it doesn't return any value as declared in int
main();
It doesn't have to!

BTW, your keyboard seems to be defective.

/S
--
Stefan Naewe
stefan_DOT_naew e_AT_atlas_DOT_ de
Feb 9 '07 #5
On Feb 9, 2:38 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>
int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.
--
Alan Johnson
yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...

As far as I know what you want to do cannot be done in standard C++.
n yr prg wont run as it doesn't return any value as declared in int
main();

Incorrect.

3.6.1/5:
A return statement in main has the effect of leaving the main
function (destroying any objects with automatic storage duration) and
calling exit with the return value as the argument. If control reaches
the end of main without encountering a return statement, the effect is
that of executing
return 0;

--
Alan Johnson
i dont know what compiler u use but mine says...Function must return a
value unless given void main();

Feb 9 '07 #6
On Feb 9, 10:24 am, "sriram" <naughtyboy...@ gmail.comwrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>
int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.

yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...
1. Yes, but since there is no support for these kinds of things in
standard C++ or in the standard library you'll either have to use a
library or write all the low-level terminal communication stuff
yourself (essentially rewriting the library).

2. Try to use whole words, it does not take that much extra time and
it make it easier to understand, especially for us non native English
speakers. Some people will not reply to posts not written in as proper
English as the poster can produce.

3. Try to remove signatures when replying to posts.

--
Erik Wikström

Feb 9 '07 #7
na***********@y ahoo.co.in wrote:
On Feb 9, 2:38 pm, Alan Johnson <a...@yahoo.com wrote:
>sriram wrote:
>>On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>
int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.
--
Alan Johnson
yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...
As far as I know what you want to do cannot be done in standard C++.
>>n yr prg wont run as it doesn't return any value as declared in int
main();
Incorrect.

3.6.1/5:
A return statement in main has the effect of leaving the main
function (destroying any objects with automatic storage duration) and
calling exit with the return value as the argument. If control reaches
the end of main without encountering a return statement, the effect is
that of executing
return 0;

--
Alan Johnson

i dont know what compiler u use but mine says...Function must return a
value unless given void main();
The compiler I use is not relevant. What is relevant is the paragraph
that I quoted from the C++ standard, which states quite clearly the
effect of control reaching the end of main without encountering a return
statement.

If your compiler does not behave that way, then it is not a C++ compiler
(despite what it might call itself).

Also, "void main()" is not now, nor has it ever been part of the C++
standard.

--
Alan Johnson
Feb 9 '07 #8
On Feb 9, 3:01 pm, "Erik Wikström" <eri...@student .chalmers.sewro te:
On Feb 9, 10:24 am, "sriram" <naughtyboy...@ gmail.comwrote:


On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>
int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that levelof
control.
yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...

1. Yes, but since there is no support for these kinds of things in
standard C++ or in the standard library you'll either have to use a
library or write all the low-level terminal communication stuff
yourself (essentially rewriting the library).

2. Try to use whole words, it does not take that much extra time and
it make it easier to understand, especially for us non native English
speakers. Some people will not reply to posts not written in as proper
English as the poster can produce.

3. Try to remove signatures when replying to posts.

--
Erik Wikström- Hide quoted text -

- Show quoted text -
thanks for your concern.
i got struck with an idea but i don hav c++ here on this pc...
i am writing the code..

#include<iostre am.h>
void main()
{
char pass[10];
cout<<"Password ";
cout.flush();//flushin std ostream
cin.tie(0);//untie cin from cout so there wont be flushing of cout
implicitly
cin>>pass;
cout<<pass;
cout.flush();
}

try this..n tel whether it works or not.

Feb 9 '07 #9
On Feb 9, 3:10 pm, "sriram" <naughtyboy...@ gmail.comwrote:
On Feb 9, 3:01 pm, "Erik Wikström" <eri...@student .chalmers.sewro te:


On Feb 9, 10:24 am, "sriram" <naughtyboy...@ gmail.comwrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.com wrote:
sriram wrote:
hi everybody,
i need a way other than using library funcs to in put a string as
password in c++ directly thro the cin object. if any body finds it pl
tel me.
#include <string>
#include <iostream>
int main()
{
std::string password ;
std::cin >password ;
std::cout << "Your password is: " << password << std::endl ;
}
If you mean you want a way to control what gets echoed on the terminal
while you type, then the iostream library doesn't give you that level of
control.
yes i wanna off the echoing in c++ as done by the getpass() func in c.
n that 2 without a library function.i m sure there must b an answer
for this...
1. Yes, but since there is no support for these kinds of things in
standard C++ or in the standard library you'll either have to use a
library or write all the low-level terminal communication stuff
yourself (essentially rewriting the library).
2. Try to use whole words, it does not take that much extra time and
it make it easier to understand, especially for us non native English
speakers. Some people will not reply to posts not written in as proper
English as the poster can produce.
3. Try to remove signatures when replying to posts.
--
Erik Wikström- Hide quoted text -
- Show quoted text -

thanks for your concern.
i got struck with an idea but i don hav c++ here on this pc...
i am writing the code..

#include<iostre am.h>
void main()
{
char pass[10];
cout<<"Password ";
cout.flush();//flushin std ostream
cin.tie(0);//untie cin from cout so there wont be flushing of cout
implicitly
cin>>pass;
cout<<pass;
cout.flush();

}

try this..n tel whether it works or not.- Hide quoted text -

- Show quoted text -
i think there might be a problem...a big problem in the code.

Feb 9 '07 #10

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

Similar topics

8
4422
by: Greg Scharlemann | last post by:
I've got a simple registration script that has an input field of type password. When I retrieve what is typed in the password field via: $_REQUEST; I always get the same encoded string: 8f404d5399b6eb816fe579381a0e2e6c First, does PHP automatically encrypt the password type fields and if so what method does it use and can I disable it?
0
294
by: Daniel Groh | last post by:
I have this method that returns a user: SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandText = "SP_Login"; SqlParameter paramEmail = new SqlParameter("@Email",SqlDbType.VarChar,60); paramEmail.Direction = ParameterDirection.Input; paramEmail.Value = strEmail.Trim();...
2
11110
by: sbox | last post by:
I've got an error "System.FormatException: Input string was not in a correct format." while I'm implementing a datagrid and a textbox What's wrong with it? Sub Button1_Click(sender As Object, e As EventArgs) DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text)) DataGrid1.DataBind() End Sub Function MyQueryMethod(ByVal others As...
5
2504
by: blackg | last post by:
Input string not in correct format -------------------------------------------------------------------------------- I am trying to view a picture from a table. I am getting this error Input string not in the correct format. Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the...
0
1401
by: PB | last post by:
According to the documentation, ParseControl returns a parsed control from an input string. The documentation seems to assume that *one* control will be parsed from the string. My implementation will require an unknown number of controls (always at least one) to be parsed from the string... after which I inject the resulting HTML into a...
1
1837
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
0
2537
by: hudhuhandhu | last post by:
have got an error which says Input string was not in a correct format. as follows.. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was...
0
3158
by: sehguh | last post by:
Hiya Folks, I am Currently using windows xp. Also using Visual Web Developer 2005 and Microsoft Sql server 2005. The main page consists of an aspx page and a master page. The page also consists of a label control(hidden when run in browser). Also an Sql data source control connected to database tables for a photo album. Also label web...
1
4512
by: sehguh | last post by:
Hello folks I have recently been studying a book called "sams teach yourself asp.net 2.0 in24 hours by scott mitchell. I have reached page 614 but when i tried to run an asp page called Photoadmin/default.aspx i got the following message and info. Input string was not in a correct format. Description: An unhandled exception occurred...
0
7684
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
8196
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
7768
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
8058
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
6400
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
5288
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3729
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3729
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1295
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.