Hello All!
I'm now creating a windows form application with login function. User need to input the id and password into two textbox. After clicking the "Login" button, the programme will compare the inputted id and password with a .txt file, if they match with each other, show a message.
Here is the text of the txt file("id" ; "password"):
james steve;123456abc
peter john;987ckja
nigel wood;456pwrd
I can only think of something like this:
#include<fstream>
private: System::Void login_Click(System::Object^ sender, System::EventArgs^ e)
String ^ tbstr1 = idbox->Text;
String ^ tbstr2 = pwbox->Text;
char *name = (char*)Marshal::StringToHGlobalAnsi(tbstr1).ToPointer();
char *password = (char*)Marshal::StringToHGlobalAnsi(tbstr2).ToPointer();
ifstream fin (“login.txt”);
if (fin) {
int count = 0;
while (!fin.eof()) {
......;
fin.getline(id, 21, ';');
fin.getline(pw, 21, ';');
......;
fin.close();
}