Видео для урока.
Код урока.
// ConsoleApplication3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream myfile;
myfile.open("login.txt");
myfile << "admin";
myfile.close();
myfile.open("password.txt");
myfile << "123";
myfile.close();
ifstream file("password.txt");
char *pass1;
pass1 = new char[100];
char *login1;
login1 = new char[100];
file.getline(pass1,'\n');
file.close();
file.open("login.txt");
file.getline(login1, '\n');
char *login;
char *password;
login = new char[100];
password = new char[100];
cout << "Enter login: ";
cin >> login;
cout << "Enter password: ";
cin >> password;
if (strcmp(login, login1) == 0 && strcmp(pass1, password) == 0)
{
cout << "Hello admin.";
}
else
{
cout << "You are wrong.";
}
cin >> password;
delete [] pass1;
delete [] login;
delete [] password;
return 0;
}
- // ConsoleApplication3.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ofstream myfile;
- myfile.open("login.txt");
- myfile << "admin";
- myfile.close();
- myfile.open("password.txt");
- myfile << "123";
- myfile.close();
- ifstream file("password.txt");
- char *pass1;
- pass1 = new char[100];
- char *login1;
- login1 = new char[100];
-
- file.getline(pass1,'\n');
- file.close();
- file.open("login.txt");
- file.getline(login1, '\n');
-
- char *login;
- char *password;
- login = new char[100];
- password = new char[100];
- cout << "Enter login: ";
- cin >> login;
- cout << "Enter password: ";
- cin >> password;
- if (strcmp(login, login1) == 0 && strcmp(pass1, password) == 0)
- {
- cout << "Hello admin.";
- }
- else
- {
- cout << "You are wrong.";
- }
- cin >> password;
- delete [] pass1;
- delete [] login;
- delete [] password;
- return 0;
- }
// ConsoleApplication3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream myfile;
myfile.open("login.txt");
myfile << "admin";
myfile.close();
myfile.open("password.txt");
myfile << "123";
myfile.close();
ifstream file("password.txt");
char *pass1;
pass1 = new char[100];
char *login1;
login1 = new char[100];
file.getline(pass1,'\n');
file.close();
file.open("login.txt");
file.getline(login1, '\n');
char *login;
char *password;
login = new char[100];
password = new char[100];
cout << "Enter login: ";
cin >> login;
cout << "Enter password: ";
cin >> password;
if (strcmp(login, login1) == 0 && strcmp(pass1, password) == 0)
{
cout << "Hello admin.";
}
else
{
cout << "You are wrong.";
}
cin >> password;
delete [] pass1;
delete [] login;
delete [] password;
return 0;
}