IfStand和OFFROW在C++中的错误
我正在为我的数据库进行注册,但编译器总是对我说: 调用“std::basic_ifstream::getlinestd::_cxx11::string&,int&”时没有匹配的函数 getText.getlinepass\u密码、数据\u计数\u密码 我不明白我的代码中的错误在哪里有人能帮我吗 代码:IfStand和OFFROW在C++中的错误,c++,file,registration,ifstream,ostream,C++,File,Registration,Ifstream,Ostream,我正在为我的数据库进行注册,但编译器总是对我说: 调用“std::basic_ifstream::getlinestd::_cxx11::string&,int&”时没有匹配的函数 getText.getlinepass\u密码、数据\u计数\u密码 我不明白我的代码中的错误在哪里有人能帮我吗 代码: #include <iostream> #include <cstring> #include <fstream> using namespace std;
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
bool is_user = false,startDatabase = false;
string file_text;
string username;
string password;
string repeat_password;
bool isCorrect = false;
int main(int argc, char const *argv[])
{
ofstream setText("user_data.txt");
ifstream getText("user_data.txt");
getText.getline(file_text,10);
if(file_text == ""){
while(!isCorrect){
cout << "For using our dataBase, please enter data for
privacy \nUsername : ";
cin >> username;
cout << "Password : ";
cin >> password;
cout << "Repeat password : ";
cin >> repeat_password;
if(password == repeat_password){
isCorrect = true;
}else{
cout << "Please, repeat and enter identistic passwords!";
isCorrect = false;
}
}
setText << username << password;
}else{
int data_count_username = username.length();
int data_count_password = password.length();
string pass_password;
string pass_username;
cout << "Please enter your data " << endl << "Username : ";
cin >> username;
cout << "Password : ";
cin >> password;
getText.getline(pass_username,data_count_username);
getText.getline(pass_password, data_count_password);
if(pass_username == username && pass_password == password){
startDatabase = true;
}
}
setText.close();
getText.close();
return 0;
}
使用:
我怎样才能修好它只需将字符串更改为字符数组?显然它接受字符*而不是字符串使用文件\u text.c\u str在页面底部有一个示例所以…..问题是字符?是的,它一定是字符*
std::getline(getText,file_text);