我不明白发生了什么事。我编译了几次程序,一切都很顺利。但是自从我插入#include <unordered_map>
后,我收到了诸如“cout 上未声明的标识符...没有 getline 的重载函数实例”之类的错误。我正在使用 Visual Studio 10。另外,如果有人能告诉我如何正确初始化unordered_map
,那就太好了。
#include "stdafx.h"
#include<string>
#include <iostream>
#include <sstream>
#include <unordered_map>
using namespace std;
unordered_map<string, dictionary * > Mymap;
int _tmain(int argc, _TCHAR* argv[])
{
string option;
string pass;
int choice=0;
unsigned char hash[20];
char hex_str[41];
while(choice!=4)
{
cout<< "Select an option:"<< endl;
cout<<"1. Basic Hashing"<<endl;
cout<<"2. Load Dictionary"<<endl;
cout<<"3. Decrypt"<<endl;
cout<<"4. Exit" <<endl;
getline(cin,option);
stringstream(option) >> choice;
if(choice == 1)
{
cout<<"Please enter a sample password"<<endl;
getline(cin,pass);
const char * c= pass.c_str();
sha1::calc(c,pass.length(), hash);
sha1::toHexString(hash,hex_str);
cout<<endl;
cout<<"Hashed: "<< hex_str<<endl;
}
else if(choice ==2)
{
string answer;
cout<<"Would you like to use the default dictionary file(d8.txt). Press y or n"<<endl;
getline(cin,answer);
}
}
return 0;
}