[英]Error with ifstream and ofstream in c++
I am making a registration, for my database, but the compiller always says to me: 我正在为我的数据库进行注册,但是编译器总是对我说:
no matching function for call to 'std::basic_ifstream::getline(std::__cxx11::string&, int&)' getText.getline(pass_password, data_count_password); 没有匹配的函数来调用'std :: basic_ifstream :: getline(std :: __ cxx11 :: string&,int&)'getText.getline(pass_password,data_count_password);
I do not understand where is the mistake in my code..Can anyone help me? 我不明白我的代码中的错误在哪里。有人可以帮助我吗?
Code : 代码:
#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;
}
采用:
std::getline(getText,file_text);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.