,   CyberForum.ru

- C++

 
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 20:11     #1
! : , .
( ), . :
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
using namespace std;
 
ifstream* openFile()
{
    ifstream* pFileStream = 0;
    for(;;)
    {
        char fileName[50] = {'l', 'o', 'g', 'i', 'n', 's', '_', 'p' ,'a', 's', 's', 'w', 'o', 'r', 'd', 's', '.', 't', 'x', 't'};
        //îòêðûâ*åì ô*éë äëÿ ÷òå*èÿ
        //*å ñîçä*â*òü, åñëè *å ñóùåñòâóåò
        pFileStream = new ifstream(fileName);
        if (pFileStream->good())
        {
            break;
        }
        cerr << "  . " << fileName << endl;
        delete pFileStream;
    }
    return pFileStream;
}
 
int register_()
{
    char login[40];
    char password[40];
    char theLogPass[100];
    cout << "  " << endl;
    cout << "->";
    cin >> login;
    cout << "  " << endl;
    cout << "->"; 
    cin >> password;
    theLogPass[100] = login[40] + password[40];
    // ç*ïèñü ä***ûõ
    ofstream fout("logins_passwords.txt", ios::app);
    fout << theLogPass;
    fout << endl;
    fout.close();
    cout << "  !!!" << endl;
}
 
int loginer()
{
    char the_log[40];
    char the_pass[40];
    char the_log_pass[100];
    cout << "  " << endl;
    cout << "->";
    cin >> the_log;
    cout << " " << endl;
    cout << "->";
    cin >> the_pass;
    the_log_pass[100] = the_log[40] + the_pass[40];
    cout << the_log_pass << endl;
    
    //ïîëó÷å*èå ô*éëîâîãî ïîòîê*
    ifstream* pFileStream = openFile();
    
    //îñò**îâèòñÿ ïî äîñòèæå*èþ êî*ö* ô*éë*
    while (!pFileStream->eof())
    {
        //÷òå*èå ç**÷å*èÿ
        char value[100];
        (*pFileStream) >> value;
        
        // îñò**îâê* ïðè îøèáêå ÷òå*èÿ
        //(**ïðèìåð, ñ÷èòûâ*åòñÿ *å öåëîå ÷èñëî, èëè
        //ñ÷èò** ñèìâîë *îâîé ñòðîêè ïîñëå êîòîðîãî 
        //*è÷åãî *åò
        if (pFileStream->fail()){
            break;
        }
        //âûâîä ñ÷èò***îãî ç**÷å*èÿ
        if(value == the_log_pass){
            cout << " " << endl;
        }else{
            cout << " !!!" << endl;
        }
    }
    delete pFileStream;
}
 
 
 
int main ()
{
    setlocale(LC_ALL, "");
    string v_log = "login";
    string v_reg = "register";
    string otvet;
    
    cout << "!!! \n   " 
    << " ." << endl;
    cout << " login    register  ." << endl;
    cout << "->";
    cin >> otvet;
    
    if(otvet == v_log){
        loginer();
    }
    if(otvet == v_reg){
        register_();
    }
    system("pause");
    return 0;
}
.
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
01.07.2014, 20:11    
:

C++
win api C++
C++
C++
C++
.
zss
 ++
   zss
5944 / 5549 / 1783
: 18.12.2011
: 14,175
: 1
01.07.2014, 20:19     #2
saharok2000
the_log_pass[100] = the_log[40] + the_pass[40];
?
string.
char
C++
1
2
strcpy(the_log_pass,the_log);
strcat(the_log_pass,the_pass)
Kerry_Jr
   Kerry_Jr
1857 / 1653 / 577
: 14.05.2014
: 4,750
: 1
: 5
01.07.2014, 20:21     #3
saharok2000
char fileName[50] = {'l', 'o', 'g', 'i', 'n', 's', '_', 'p' ,'a', 's', 's', 'w', 'o', 'r', 'd', 's', '.', 't', 'x', 't'};
,
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 20:38  []     #4
zss, .
Kerry_Jr, , .

6
zss,
[Error] 'strcpy' was not declared in this scope
nmcf
4297 / 3718 / 1251
: 14.04.2014
: 14,540
01.07.2014, 20:44     #5
<cstring>.
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 20:46  []     #6
nmcf
<cstring>.
,
Kerry_Jr
   Kerry_Jr
1857 / 1653 / 577
: 14.05.2014
: 4,750
: 1
: 5
01.07.2014, 21:03     #7
saharok2000
, .
, , . .
C++
1
char fileName[50] = "logins_passwords.txt";
, , .
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 21:14  []     #8
Kerry_Jr, string;

C++
1
2
string fileName = "logins_passwords.txt";
pFileStream = new ifstream(fileName);

C++
1
pFileStream = new ifstream("logins_passwords.txt");
nmcf
4297 / 3718 / 1251
: 14.04.2014
: 14,540
01.07.2014, 21:17     #9
new?
C++
1
ifstream ifs(fileName);
recoder
   recoder
129 / 129 / 28
: 13.09.2013
: 260
: 2
01.07.2014, 21:17     #10
C++
1
std::ifstream inFile(filename);


C++
1
2
3
4
5
std::cin.getline(filename, SIZE);
std::ifstream inFile;
inFile.open(filename);
if ( !inFile.is_open() )
{ ... }
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 21:28  []     #11
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;
 
ifstream* openFile()
{
    ifstream* pFileStream = 0;
    for(;;)
    {
        char fileName[50] = {'l', 'o', 'g', 'i', 'n', 's', '_', 'p' ,'a', 's', 's', 'w', 'o', 'r', 'd', 's', '.', 't', 'x', 't'};
        //îòêðûâ*åì ô*éë äëÿ ÷òå*èÿ
        //*å ñîçä*â*òü, åñëè *å ñóùåñòâóåò
        pFileStream = new ifstream(fileName);
        if (pFileStream->good())
        {
            break;
        }
        cerr << "Íåâîçìîæ*î îòêðûòü ô*éë " << fileName << endl;
        delete pFileStream;
    }
    return pFileStream;
}
 
int register_()
{
    char login[40];
    char password[40];
    char theLogPass[100];
    cout << "Ïðèäóì*éòå ëîãè* " << endl;
    cout << "->";
    cin >> login;
    cout << "Ïðèäóì*éòå ï*ðîëü " << endl;
    cout << "->"; 
    cin >> password;
    strcpy(theLogPass,login);
    strcat(theLogPass,password);
 
    // ç*ïèñü ä***ûõ
    ofstream fout("logins_passwords.txt", ios::app);
    fout << theLogPass;
    fout << endl;
    fout.close();
    cout << "Âû óñïåø*î ç*ðåãèñòðèðîâ**û!!!" << endl;
}
 
int loginer()
{
    char the_log[40];
    char the_pass[40];
    char the_log_pass[100];
    cout << "Ââåäèòå ñâîé ëîãè*" << endl;
    cout << "->";
    cin >> the_log;
    cout << "Ââåäèòå ï*ðîëü" << endl;
    cout << "->";
    cin >> the_pass;
    strcpy(the_log_pass,the_log);
    strcat(the_log_pass,the_pass);
    cout << the_log_pass << endl;
    
    //ïîëó÷å*èå ô*éëîâîãî ïîòîê*
    ifstream* pFileStream = openFile();
    
    //îñò**îâèòñÿ ïî äîñòèæå*èþ êî*ö* ô*éë*
    while (!pFileStream->eof())
    {
        //÷òå*èå ç**÷å*èÿ
        char value[100];
        (*pFileStream) >> value;
        
        // îñò**îâê* ïðè îøèáêå ÷òå*èÿ
        //(**ïðèìåð, ñ÷èòûâ*åòñÿ *å öåëîå ÷èñëî, èëè
        //ñ÷èò** ñèìâîë *îâîé ñòðîêè ïîñëå êîòîðîãî 
        //*è÷åãî *åò
        if (pFileStream->fail()){
            break;
        }
        //âûâîä ñ÷èò***îãî ç**÷å*èÿ
        if(value == the_log_pass){
            cout << "Äîñòóï ð*çðåøå*" << endl;
        }else{
            cout << "Îøèáê* *ó*òåôèê*öèè!!!" << endl;
        }
    }
    delete pFileStream;
}
 
 
 
int main ()
{
    setlocale(LC_ALL, "");
    string v_log = "login";
    string v_reg = "register";
    string otvet;
    
    cout << "Ïðèâåò ÷åëîâåê!!! \n×òîáû ïîï*ñòü â ìèð êîìïüþòåð* " 
    << "*åîáõîäèìî âîéòè èëè ç*ðåãèñòðèðîâ*òüñÿ." << endl;
    cout << "Ââåäèòå login ÷òîáû âîéòè èëè register äëÿ ðåãèñòð*öèè." << endl;
    cout << "->";
    cin >> otvet;
    
    if(otvet == v_log){
        loginer();
    }
    if(otvet == v_reg){
        register_();
    }
    system("pause");
    return 0;
}
nmcf
4297 / 3718 / 1251
: 14.04.2014
: 14,540
01.07.2014, 21:43     #12
82- - , strcmp(). . string, , .
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 21:52  []     #13
nmcf
82- - , strcmp(). . string, , .
- ( )
nmcf
4297 / 3718 / 1251
: 14.04.2014
: 14,540
01.07.2014, 21:54     #14
C++
1
if(strcmp(value, the_log_pass))
saharok2000
1 / 1 / 0
: 01.07.2014
: 49
02.07.2014, 19:41  []     #15
nmcf,

21 36
, ... 82
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;
 
ifstream* openFile()
{
    ifstream* pFileStream = 0;
    for(;;)
    {
        char fileName[50] = {'l', 'o', 'g', 'i', 'n', 's', '_', 'p' ,'a', 's', 's', 'w', 'o', 'r', 'd', 's', '.', 't', 'x', 't'};
        //îòêðûâ*åì ô*éë äëÿ ÷òå*èÿ
        //*å ñîçä*â*òü, åñëè *å ñóùåñòâóåò
        pFileStream = new ifstream(fileName);
        if (pFileStream->good())
        {
            break;
        }
        cerr << "Íåâîçìîæ*î îòêðûòü ô*éë " << fileName << endl;
        delete pFileStream;
    }
    return pFileStream;
}
 
int register_()
{
    char login[40];
    char password[40];
    char theLogPass[100];
    cout << "Ïðèäóì*éòå ëîãè* " << endl;
    cout << "->";
    cin >> login;
    cout << "Ïðèäóì*éòå ï*ðîëü " << endl;
    cout << "->"; 
    cin >> password;
    strcpy(theLogPass,login);
    strcat(theLogPass,password);
 
    // ç*ïèñü ä***ûõ
    ofstream fout("logins_passwords.txt", ios::app);
    fout << theLogPass;
    fout << endl;
    fout.close();
    cout << "Âû óñïåø*î ç*ðåãèñòðèðîâ**û!!!" << endl;
}
 
int loginer()
{
    char the_log[40];
    char the_pass[40];
    char the_log_pass[100];
    cout << "Ââåäèòå ñâîé ëîãè*" << endl;
    cout << "->";
    cin >> the_log;
    cout << "Ââåäèòå ï*ðîëü" << endl;
    cout << "->";
    cin >> the_pass;
    strcpy(the_log_pass,the_log);
    strcat(the_log_pass,the_pass);
    cout << the_log_pass << endl;
    
    //ïîëó÷å*èå ô*éëîâîãî ïîòîê*
    ifstream* pFileStream = openFile();
    
    //îñò**îâèòñÿ ïî äîñòèæå*èþ êî*ö* ô*éë*
    while (!pFileStream->eof())
    {
        //÷òå*èå ç**÷å*èÿ
        char value[100];
        (*pFileStream) >> value;
        
        // îñò**îâê* ïðè îøèáêå ÷òå*èÿ
        //(**ïðèìåð, ñ÷èòûâ*åòñÿ *å öåëîå ÷èñëî, èëè
        //ñ÷èò** ñèìâîë *îâîé ñòðîêè ïîñëå êîòîðîãî 
        //*è÷åãî *åò
        if (pFileStream->fail()){
            break;
        }
        //âûâîä ñ÷èò***îãî ç**÷å*èÿ
        if(strcmp(value, the_log_pass)){
            cout << "Äîñòóï ð*çðåøå*" << endl;
        }else{
            cout << "Îøèáê* *ó*òåôèê*öèè!!!" << endl;
            cout << "value        = " << value << endl;
            cout << "the_log_pass = " << the_log_pass << endl;
            
        }
    }
    delete pFileStream;
}
 
 
 
int main ()
{
    setlocale(LC_ALL, "");
    string v_log = "login";
    string v_reg = "register";
    string otvet;
    
    cout << "Ïðèâåò ÷åëîâåê!!! \n×òîáû ïîï*ñòü â ìèð êîìïüþòåð* " 
    << "*åîáõîäèìî âîéòè èëè ç*ðåãèñòðèðîâ*òüñÿ." << endl;
    cout << "Ââåäèòå login ÷òîáû âîéòè èëè register äëÿ ðåãèñòð*öèè." << endl;
    cout << "->";
    cin >> otvet;
    
    if(otvet == v_log){
        loginer();
    }
    if(otvet == v_reg){
        register_();
    }
    system("pause");
    return 0;
}
MoreAnswers
37091 / 29110 / 5898
: 17.06.2006
: 43,301
02.07.2014, 20:19    
:

C++ dll Linux
! C++
? C++



:
nmcf
4297 / 3718 / 1251
: 14.04.2014
: 14,540
02.07.2014, 20:19     #16
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
 
using namespace std;
 
void register_()
{
    char login[40], password[40];
 
    cout << "  " << endl;
    cout << "->";
    cin.getline(login, 40);
    cout << "  " << endl;
    cout << "->"; 
    cin.getline(password, 40);
    //  
    ofstream ofs("logins_passwords.txt", ios::app);
    ofs << login << password << endl;
    ofs.close();
    cout << "  !!!" << endl;
}
 
void loginer()
{
    char the_log[40], the_pass[40], the_log_pass[100];
 
    cout << "  " << endl;
    cout << "->";
    cin.getline(the_log, 40);
    cout << " " << endl;
    cout << "->";
    cin.getline(the_pass, 40);
    strcpy(the_log_pass, the_log);
    strcat(the_log_pass, the_pass);
    //  
    ifstream ifs("logins_passwords.txt");
    if(!ifs)
    {
        cerr << "   " << "logins_passwords.txt" << endl;
        return;
    }
    char value[100];
    //    
    while (!ifs.eof())
    {
        // 
        ifs.getline(value, 100);
        
        //    
        //(,    , 
        //      
        // 
        if (ifs.fail()){
            break;
        }
        //  
        if(strcmp(value, the_log_pass) == 0)
        {
            cout << " " << endl;
            ifs.close();
            return;
        }
    }
    cout << " !!!" << endl;
        ifs.close();
}
 
int _tmain(int argc, _TCHAR* argv[])
{
    setlocale(LC_ALL, "");
    string v_log = "login";
    string v_reg = "register";
    string otvet;
    
    cout << " !!! \n     " 
            << "   ." << endl;
    cout << " login    register  ." << endl;
    cout << "->";
    getline(cin, otvet);
    
    if(otvet == v_log){
        loginer();
    }
    else
        if(otvet == v_reg){
            register_();
        }
 
    system("pause");
    return 0;
}
Yandex
02.07.2014, 20:19    

: 17:15. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru