473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 9434
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.comwrote:
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.comwrote:
>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.comwrote:
>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_naewe_AT_atlas_DOT_de
Feb 9 '07 #5
On Feb 9, 2:38 pm, Alan Johnson <a...@yahoo.comwrote:
sriram wrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.comwrote:
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.comwrote:
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***********@yahoo.co.in wrote:
On Feb 9, 2:38 pm, Alan Johnson <a...@yahoo.comwrote:
>sriram wrote:
>>On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.comwrote:
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.sewrote:
On Feb 9, 10:24 am, "sriram" <naughtyboy...@gmail.comwrote:


On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.comwrote:
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<iostream.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.sewrote:


On Feb 9, 10:24 am, "sriram" <naughtyboy...@gmail.comwrote:
On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.comwrote:
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<iostream.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
sriram wrote:
On Feb 9, 3:01 pm, "Erik Wikström" <eri...@student.chalmers.sewrote:
>On Feb 9, 10:24 am, "sriram" <naughtyboy...@gmail.comwrote:


>>On Feb 9, 2:16 pm, Alan Johnson <a...@yahoo.comwrote:
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<iostream.h>
void main()
http://www.parashift.com/c++-faq-lit....html#faq-29.3

- J.
Feb 9 '07 #11
sriram <na***********@gmail.comwrote:
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...
http://www.parashift.com/c++-faq-lit...html#faq-15.18
n yr prg wont run as it doesn't return any value as declared in int
main();
http://www.parashift.com/c++-faq-lit....html#faq-29.3

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Feb 9 '07 #12
na***********@yahoo.co.in wrote:

i dont know what compiler u use but mine says...Function must return a
value unless given void main();
Is that a warning? Implementations are allowed to issue any warnings
they want, regardless of whether the construct is valid code or not.
Many give a warning for this:
if (i = 1)
{
// do stuff
}
That's not because it's nonstandard code, but because it probably
represents a programmer error. Similarly missing return statements from
main() may mean the programmer forgot.

Brian
Feb 9 '07 #13
"sriram" <na***********@gmail.comwrote in message
news:11**********************@a34g2000cwb.googlegr oups.com...
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.
I know of no standard C++ way to do this. Anything you come up with will be
OS specific. If you don't need anything cross platform then try asking in a
newsgroup appropriate to your OS and maybe something could be come up with.
Feb 9 '07 #14

Jim Langston wrote:
>>
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.

I know of no standard C++ way to do this. Anything you come up with will
be OS specific. If you don't need anything cross platform then try asking
in a newsgroup appropriate to your OS and maybe something could be come up
with.
If there is no standard way, but program must be portable, make interface to
all target specific functions, so to port on concrete platform you will make
implementation of the interface.

//input with waiting, no echo
namespace Nwin95{void getch();}
namespace Nmsdos{void getch();}
namespace Nlinux{void getch();}

using Nxxx::getch;

--
Maksim A. Polyanin

"In thi world of fairy tales rolls are liked olso"
/Gnume/
Feb 11 '07 #15

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

Similar topics

8
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:...
0
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...
2
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...
5
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...
0
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...
1
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
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...
0
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.