正在尝试创建密码登录

Trying to create a password logon

本文关键字:密码 登录 创建      更新时间:2023-10-16

简而言之,我不确定以前是否有人问过这个问题,但我所做的研究一无所获。我目前正在自学c++,并认为创建某种用户名和密码登录会很好(由于代码问题,我只有密码的结构),使其成为在AWS服务器上运行的ssh into-able程序。根据我所做的研究,我似乎应该做这样的

#include <string>
#include <string.h>
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
string input;
cout << "Enter PW" << endl;
cin >> input;
cout << input << "was what you set" << endl;
}

显然,最终它不会回显密码,我相信这不是最安全的处理方式。每次我试图在Microsoft Visual Studio IDE中编译和运行代码时,都会出现两个错误,这两个错误将我带到

cin >> input; 

cout << input << "was what you set" << endl;

Error:  C2679   binary '>>': no operator found which takes a right-hand 
operand of type 'std::string' (or there is no acceptable conversion)    
Error   C2679   binary '<<': no operator found which takes a right-hand 
operand of type 'std::string' (or there is no acceptable conversion)    

https://i.stack.imgur.com/qcpXJ.png这是IDE中的控制台应用程序,上面的照片应该包含所有的代码和错误。如果有任何帮助,我们将不胜感激,因为我可以告诉您,只有当我使用字符串变量时,问题才会出现。如果我做的事情完全错了,可以自由告诉我。

干杯!

您在iostream和conio.h 中错过了.h

#include <string.h>
#include "pch.h"
#include <iostream.h>
#include <conio.h>
using namespace std;
int main()
{
string input;
cout << "Enter PW" << endl;
cin >> input;
cout << input << "was what you set" << endl;
}