如何输入字符串作为密码。 [英] how to input string as password.

查看:124
本文介绍了如何输入字符串作为密码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


除了使用库函数之外我还需要一种方法来直接在cin对象中输入一个字符串作为c ++中的
密码。如果有人发现它,请打电话给我。

解决方案

sriram写道:
< blockquote class =post_quotes>
嗨大家好,


i需要一种方法,而不是使用库funcs来输入字符串

密码in c ++直接通过cin对象。如果有人发现它,请打电话给我。



#include< string>

#include< ; iostream>


int main()

{

std :: string password;

std :: cin>密码;

std :: cout<< 您的密码是: <<密码<< std :: endl;

}

如果你的意思是你想要一种方法来控制你在键入时在终端上回显的内容

,那么iostream库没有给你那个级别的

控制。


-

Alan Johnson


2月9日下午2:16,Alan Johnson< a ... @ yahoo.comwrote:


sriram写道:


hi everybody,


i需要一种方法,而不是使用库函数来在c ++中直接输入一个字符串作为

密码。如果有人发现它,请给我打电话。



#include< string>

#include< iostream>


int main ()

{

std :: string password;

std :: cin>密码;

std :: cout<< 您的密码是: <<密码<< std :: endl;


}


如果你的意思是想要一种方法来控制在终端上回应的东西
$当你输入时,b $ b,那么iostream库并没有给你那个级别的

控制。


-

Alan Johnson



是的我想要离开c ++中的回声,就像c中的getpass()函数所做的那样。

n那2没有一个库函数。我确定必须有一个答案

这个......


n你的prg不会运行因为它没有返回任何值在int中声明

main();


sriram写道:


2月9日下午2:16,Alan Johnson< a ... @ yahoo.comwrote:


> sriram写道:


>>大家好,
我需要一种方法,而不是使用库funcs将字符串作为密码在c ++中直接放入cin o bject。如果有人发现它,请给我打电话。


#include< string>
#include< iostream>

int main()
{
std :: string password;
std :: cin>密码;
std :: cout<< 您的密码是: <<密码<< std :: endl;

}

如果你想要一种方法来控制你在键入时在终端上回显的内容,那么iostream库就不会不要给你那种级别的控制权。

-
Alan Johnson



是的我想离开c ++中的回显由c中的getpass()函数完成。

n那2没有库函数。我确定必须回答

这个...



据我所知,你不想用标准C ++做什么。


n yr prg不会运行因为它没有返回int中声明的任何值

main();



不正确。


3.6.1 / 5:

main中的return语句具有离开main

函数的效果(使用自动存储功能销毁任何对象)持续时间)和

以返回值作为参数调用exit。如果控制达到

主结束没有遇到退货声明,效果是

执行

返回0;

-

Alan Johnson


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.

解决方案

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


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();


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


这篇关于如何输入字符串作为密码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆