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();
}

This looks like some kind of Microsoft C++ variant. Managed C++, or some kind of C#, or some such. You might have more luck asking in that forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.