0 / 0 / 0
Регистрация: 02.04.2015
Сообщений: 19
1

Error LNK1120, Error LNK2019

03.04.2015, 17:13. Показов 865. Ответов 2
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Здравствуйте . У меня проблема с кодом .

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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string.h>
 
#pragma warning(disable:4996)
 
using namespace std;
struct planeStruct
{
    char tname[64];
    int airport;
    char **stList;
    int seats;
    int sectora;
    int ***tickets;
};
 
int ExtractPlaneTickets(planeStruct PlaneInfo);
int ExtractPlanePyti(planeStruct *PlaneInfo);
void SavePlaneTickets(planeStruct *PlaneInfo, int n);
int GetPossiblePyti(planeStruct PlaneInfo);
int IsPlaneExists(char plane_name[], planeStruct *PlaneInfo, int n);
void ShowPlaneInfo(planeStruct planeInfo);
 
int main()
{
    setlocale(0, "Russian");
    ifstream fin("C:\\Games\\Visual Studio\\Pyti.txt");
    if (!fin)
    {
        cout << "Не можу вiдкрити файл pyti.txt";
        _getch();
        return 0;
    }
    int n = 0;
    char string[128];
    while (!fin.eof())
    {
        fin.getline(string, 128);
        n++;
    }
    fin.close();
    planeStruct *PlaneInfo = new planeStruct[n];
    int planes = ExtractPlanePyti(PlaneInfo);
    if (planes != n) return 0;
 
    ifstream tin("C:\\Games\\Visual Studio\\tickets.txt");
 
    if (tin)
    {
        for (int i = 0; i < n; i++)
            ExtractPlaneTickets(PlaneInfo[i]);
    }
    else
    {
        for (int t = 0; t < n; t++)
        {
            int c_pyti = GetPossiblePyti(PlaneInfo[t]);
            for (int i = 0; i < c_pyti; i++)
            for (int j = 0; j < PlaneInfo[t].sectora; j++)
            for (int x = 0; x < PlaneInfo[t].seats; x++)
                PlaneInfo[t].tickets[i][j][x] = 0;
        }
        SavePlaneTickets(PlaneInfo, n);
    }
    // виводимо список всіх літаків, а також їх рейсів
    for (int i = 0; i < n; i++)
    {
        cout << i + 1 << ") " << PlaneInfo[i].tname << ": Рейс:";
        for (int j = 0; j < PlaneInfo[i].airport; j++)
        {
            cout << PlaneInfo[i].stList[j];
            if (j != PlaneInfo[i].airport - 1) cout << " - ";
        }
        cout << endl;
    }
    //------------------------------------
    while (true)
    {
        char plane_name[64];
        int id = -1;
        cout << endl << "Введiть назву лiтака:\n";
        cin.getline(plane_name, 64);
        while (IsPlaneExists(plane_name, PlaneInfo, n) == -1)
        {
            cout << "Лiтак з такю назвою не iснує!" << endl;
            cout << "Введiть назву лiтака:\n";
            cin.getline(plane_name, 64);
        }
        id = IsPlaneExists(plane_name, PlaneInfo, n);
        //ShowPlaneInfo(PlaneInfo[id]);
        // робота користувача
        while (true)
        {
            cout << endl << "Введiть номер сектора (макc. " << PlaneInfo[id].sectora << "): " << endl;
            int b = 0;
            cin >> b;
            while (b < 1 || b > PlaneInfo[id].sectora)
            {
                cout << "Не вiрний номер сектора!" << endl;
                cin >> b;
            }
            cout << "Сектор №" << b << ":\n";
            b--; // зменшуємо на 1, тому намерація йде від 0
            cout << endl << "Выберите от куда и куда нужно ехать Виберiть вiд куди i куди потрiбно їхати:\n";
            int w = 0;
            int pyti = GetPossiblePyti(PlaneInfo[id]), k = 0;
            for (int i = 0; i < PlaneInfo[id].airport - 1; i++)
            for (int j = i + 1; j < PlaneInfo[id].airport; j++)
            {
                cout << k + 1 << ") " << PlaneInfo[id].stList[i] << " - " << PlaneInfo[id].stList[j] << endl;
                k++;
            }
            do
            {
                cout << "Введiть номер пункта: ";
                cin >> w;
            } while (w > pyti || w < 1);
            w--;
            cout << endl << "Пошук першого вiльного мiсця..." << endl;
            int num = -1;
            for (int i = 0; i < PlaneInfo[id].seats; i++)
            {
                if (PlaneInfo[id].tickets[w][b][i] == 0)
                {
                    PlaneInfo[id].tickets[w][b][i] = 1;
                    num = i;
                    break;
                }
            }
            cout << "Список мiсць:" << endl << "№  статус" << endl;
            for (int i = 0; i < PlaneInfo[id].seats; i++)
            {
                if (PlaneInfo[id].tickets[w][b][i] == 1)
                    cout << i + 1 << ": продано; " << endl;
                else
                    cout << i + 1 << ": вiльно; " << endl;
            }
            if (num == -1) cout << endl << "\n!!! Не було знайдено жодного вiльного мiсця на даному промiжку i в даному секторi !!!" << endl;
            else cout << "\nПерше знайдене вiльне мiсце, номер: " << num + 1 << " i було вiдзначено як продане " << endl;
            cout << "-------------------------------------------" << endl;
            SavePlaneTickets(PlaneInfo, n);
        }
    }
    _getch();
    return 1;
}
int IsTrainExists(char train_name[], planeStruct *TrainInfo, int n)
{
    for (int i = 0; i < n; i++)
    if (strcmp(train_name, TrainInfo[i].tname) == 0)
        return i;
    return -1;
}
int ExtractTrainTickets(planeStruct TrainInfo)
{
    ifstream tin("C:\\Games\\Visual Studio\\tickets.txt");
    char string[1024], *tmp;
    int n = 0;
    while (!tin.eof())
    {
        tin.getline(string, 1024);
        char *name = strtok(string, ":");
        if (name == NULL) continue;
        if (strcmp(TrainInfo.tname, name)) continue;
        char *pyti = strtok(NULL, ":");
        int c_ways = GetPossiblePyti(TrainInfo);
        char **w = new char *[c_ways];
        // витягаємо частина рядка з файлу зі списком секторів з інформацією про квитки на можливих проміжках і записуємо в двовимірний масив w
        // результат витягування: w [ j ] = " w = 0,0 , ...., 0 " - де j - індекс проміжку від усього шляху
        if (pyti[0] != 'w')
        {
            for (int i = 0; i < c_ways; i++)
            for (int j = 0; j < TrainInfo.sectora; j++)
            for (int x = 0; x < TrainInfo.seats; x++)
                TrainInfo.tickets[i][j][x] = 0;
            continue;
        }
        else
        {
            w[0] = strtok(pyti, "|");
            for (int i = 1; i < c_ways; i++)
                w[i] = strtok(NULL, "|");
            /*for(int i = 0; i < c_ways; i++)
            if(w[i] != NULL) cout<<w[i]<<endl;*/
        }
        //-------------------------
        //cout<<"-----------------------"<<endl;
        // з отриманого списку секторів витягаємо інформацію про квитки на кожному проміжку в кожному секторі
        // в результаті повинні отримати : " 0,0 , .... 0" - і в цьому ж циклі буде записувати цифри в структурі з квитками
        for (int i = 0; i < c_ways; i++)
        {
            char **wagonslist = new char*[TrainInfo.sectora];
            tmp = strtok(w[i], "=");
            tmp = strtok(NULL, "=");
            wagonslist[0] = strtok(tmp, "_");
            for (int j = 1; j < TrainInfo.sectora; j++)
                wagonslist[j] = strtok(NULL, "_");
 
            tmp = NULL;
            for (int j = 0; j < TrainInfo.sectora; j++)
            {
                if (wagonslist[j] != NULL)
                {
                    tmp = strtok(wagonslist[j], ",");
                    for (int x = 0; x < TrainInfo.seats; x++)
                    {
                        if (tmp != NULL)
                        {
                            TrainInfo.tickets[i][j][x] = atoi(tmp);
                            tmp = strtok(NULL, ",");
                        }
                    }
                }
            }
        }
        n++;
    }
    return n;
}
int ExtractPlanePyti(planeStruct *TrainInfo)
{
    ifstream fin("C:\\Games\\Visual Studio\\pyti.txt");
    fin.clear();
    fin.seekg(0);
    int n = 0;
    char *tmp;
    char string[128];
    while (!fin.eof())
    {
        fin.getline(string, 128);
        char str[64];
        strcpy(str, string);
        tmp = strtok(str, ",");
        int fairport = 0;
        while (tmp != NULL)
        {
            fairport++;
            tmp = strtok(NULL, ",");
        }
        fairport -= 2;
        TrainInfo[n].airport = fairport;
        TrainInfo[n].stList = new char *[fairport];
        strcpy(str, string);
        tmp = strtok(str, ",");
        for (int i = 0; i < fairport; i++)
        {
            TrainInfo[n].stList[i] = new char[32];
            strcpy(TrainInfo[n].stList[i], tmp);
            tmp = strtok(NULL, ",");
        }
        strcpy(TrainInfo[n].tname, TrainInfo[n].stList[0]);
        strcat(TrainInfo[n].tname, " - ");
        strcat(TrainInfo[n].tname, TrainInfo[n].stList[fairport - 1]);
        TrainInfo[n].sectora = atoi(tmp);
        tmp = strtok(NULL, ",");
        TrainInfo[n].seats = atoi(tmp);
 
        n++;
    }
    cout << endl << endl;
    for (int m = 0; m < n; m++)
    {
        int pyti = GetPossiblePyti(TrainInfo[m]);
        TrainInfo[m].tickets = new int **[pyti];
        for (int i = 0; i < pyti; i++)
        {
            TrainInfo[m].tickets[i] = new int *[TrainInfo[m].sectora];
            for (int j = 0; j < TrainInfo[m].sectora; j++)
            {
                TrainInfo[m].tickets[i][j] = new int[TrainInfo[m].seats];
                for (int x = 0; x < TrainInfo[m].seats; x++)
                    TrainInfo[m].tickets[i][j][x] = 0;
            }
        }
        //ShowPlaneInfo(PlaneInfo[m]);
    }
 
    //SavePlaneTickets(PlaneInfo, n);
    return n;
}
 
void SavePlaneTickets(planeStruct *PlaneInfo, int n)
{
    ofstream fout("C:\\Games\\Visual Studio\\tickets.txt");
    for (int m = 0; m < n; m++)
    {
        int pyti = GetPossiblePyti(PlaneInfo[m]);
        //cout<<endl<<PlaneInfo[m].tname<<" "<<PlaneInfo[m].sectora<<" "<<PlaneInfo[m].seats<<endl;
        fout << PlaneInfo[m].tname << ":";
        for (int i = 0; i < pyti; i++)
        {
            fout << "w=";
            for (int j = 0; j < PlaneInfo[m].sectora; j++)
            {
                for (int x = 0; x < PlaneInfo[m].seats; x++)
                {
                    if (x != PlaneInfo[m].seats - 1)
                        fout << PlaneInfo[m].tickets[i][j][x] << ",";
                    else
                        fout << PlaneInfo[m].tickets[i][j][x];
                }
                fout << "_";
            }
            fout << "|";
        }
        fout << endl;
    }
}
 
void ShowPlaneInfo(planeStruct TrainInfo)
{
    int pyti = GetPossiblePyti(TrainInfo);
    cout << endl << TrainInfo.tname << " " << TrainInfo.sectora << " " << TrainInfo.seats << endl;
    for (int i = 0; i < pyti; i++)
    {
        cout << i + 1 << ") ";
        for (int j = 0; j < TrainInfo.sectora; j++)
        {
            for (int x = 0; x < TrainInfo.seats; x++)
                cout << TrainInfo.tickets[i][j][x] << " ";
            cout << "  ";
        }
        cout << endl;
    }
}
int GetPossiblePyti(planeStruct TrainInfo)
{
    int pyti = 0, fairport = TrainInfo.airport;
    for (int i = 0; i < fairport - 1; i++)
    for (int j = i + 1; j < fairport; j++)
        pyti++;
    return pyti;
}
Ошибка 2 error LNK2019: ссылка на неразрешенный внешний символ "int __cdecl IsPlaneExists(char * const,struct planeStruct *,int)" (?IsPlaneExists@@YAHQADPAUplaneStruct@@H@Z) в функции _main

Ошибка 1 error LNK2019: ссылка на неразрешенный внешний символ "int __cdecl ExtractPlaneTickets(struct planeStruct)" (?ExtractPlaneTickets@@YAHUplaneStruct@@@Z) в функции _main

Ошибка 3 error LNK1120: неразрешенных внешних элементов: 2

Не подскажите что с этим делать ?

Заранее спасибо.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
03.04.2015, 17:13
Ответы с готовыми решениями:

Error LNK1120, error LNK2019, error LNK2028, queue
// свойство класса Parser queue&lt;elem*&gt;* postfix = new queue&lt;elem*&gt;; // строка, из-за...

Error LNK2019 и fatal error LNK1120
Копаюсь в гугле уже часа 2. Не понимаю, в чем проблема. Вроде нигде ошибок в коде нету, но выдает:...

Error LNK2019 и LNK1120
Форумчане, помогите кто чем может. изучать язык только начал, поэтому куча вопросов и ошибок, а...

Ошибка error LNK2019 & LNK1120 и md5()
Добавил поддержку md5(), код с сайта http://www.zedwood.com/article/cpp-md5-function Пробую...

2
Модератор
Эксперт С++
13254 / 10394 / 6214
Регистрация: 18.12.2011
Сообщений: 27,807
03.04.2015, 17:16 2
Написать код для функций IsPlaneExists и ExtractPlaneTickets.
Вы их объявили, а описать запамятовали.
Если они в другом файле, то тоже подключите его к проекту.

p.s. В коде есть функции IsTrainExists и ExtractTrainTickets.
Может это они?
0
Модератор
Эксперт по электронике
8811 / 6593 / 896
Регистрация: 14.02.2011
Сообщений: 23,185
03.04.2015, 17:17 3
нет реализаций функций ExtractPlaneTickets и IsPlaneExists
0
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
03.04.2015, 17:17
Помогаю со студенческими работами здесь

Error LNK2028, LNK2019, LNK1120: 2 неразрешенных внешних элементов
Всем привет. #include &quot;stdafx.h&quot; #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &quot;conio.h&quot;...

error LNK1120
#include &quot;stdafx.h&quot; #include &lt;iostream&gt; #include &lt;conio.h&gt; #include &lt;vector&gt; using namespace...

Fatal error LNK1120:
Output: ------ Построение начато: проект: Lab1, Конфигурация: Debug Win32 ------ 1&gt; Lab1.cpp...

fatal error LNK1120
Всем привет. При компиляции выбивает такую ошибку: 1&gt;LINK : error LNK2001: неразрешенный внешний...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2023, CyberForum.ru