Linker Error

I compiled the file, it showed no errors in Turbo C++. But when I run it , I get this error - "Linker Error: Unable to open file '..\SOURCE\MAIN.EXE'. I deleted the file and again pasted the file in the same directory but it showed the same error.
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<stdio.h>
#include<stdlib.h>
char ch;
fstream f;
enum Vacancy{Vacant,NotVacant};
enum Service{Pending,Done};
struct date
{
    int dd,mm,yy;
};

struct address
{   int houseno;
    char locality[50];
    char city[50];
};
class ROOM
{   private:
    int id;
    int members;
    char name[50];
    address house;
    public:
    int no;
    ROOM()
    {   no=0;
        id=0;
        members=0;
        strcpy(name,"NULL");
        house.houseno=0;
        strcpy(house.locality,"NULL");
        strcpy(house.city,"NULL");
        dcheckin.dd=0;
        dcheckin.mm=0;
        dcheckin.yy=0;
        dcheckout.dd=0;
        dcheckout.mm=0;
        dcheckout.yy=0;


    }
    void GETDATA();
    void PUTDATA();
    date dcheckin;
    date dcheckout;
    int retid()
    {
        return id;
    }
    char *retname()
    {
        return name;
    }
}s;
 void DISPLAYALL();
 void VACSER();
    void STATUS(int);
    void CHECKIN(int);
    void CHECKOUT(int);
    void EXCHANGE(int,int);
    void SEARCH(int);
    void SEARCH(char *);
    void MODIFY(int);
    void DELFILE(int val);
    void WRITEFILE();
    //void DISPLAY(int);//
class hotel
{   public:
    int id;
    Service scondition;
    Vacancy vcondition;
    hotel()
    {
        id=0;
        vcondition=Vacant;
        scondition=Done;
    }

}set[10];
void MENU();
void MENU()
{
    int choice,a,b,n,i;
Y:  system("cls");
    cout<<"\t \t \t Welcome to THE INCEPTION HOTEL \n";
    cout<<"1.Book a room\n";
    cout<<"2.Check info of a room\n";
    cout<<"3.Check in\n";
    cout<<"4.Check out\n";
    cout<<"5.Service requests and Vacancies\n";
    cout<<"6.Display all \n";
    cout<<"7.Exchange\n";
    cout<<"8.Search by name\n";
    cout<<"9.Search by customer id\n";
    cout<<"10.Modify\n";
    cout<<"11.Exit \n";
    cout<<"Enter choice \n";
    cin>>choice;
    switch(choice)
    {
    case 1:
    WRITEFILE();
    break;

	case 2:
	cout<<"Enter the room no \n";
    cin>>i;
	STATUS(i);
	break;

	case 3:
	cout<<"Enter room no\n";
    cin>>i;
	CHECKIN(i);
	break;

	case 4:
	cout<<"Enter room no\n";
    cin>>i;
	CHECKOUT(i);
	break;

	case 5:
	VACSER();
	break;

	case 6:
	DISPLAYALL();
	break;

	case 7:
	cout<<"Enter the room no you want to exchange\n ";
	cin>>a;
	cout<<"Enter the room no you want to exchange with\n";
	cin>>b;
	EXCHANGE(a,b);
	break;

	case 8:
	char sname[20];
	cout<<"Enter name you want to search for?\n";
	cin.getline(sname,sizeof(sname));
	cin.get(ch);
	SEARCH(sname);
	break;

	case 9:
	int id;
	cout<<"Enter id you want to search for?\n";
	cin>>id;
	SEARCH(id);

	case 10:
	cout<<"Enter customer id whose info is to be modified\n";
	cin>>n;
	MODIFY(n);
	break;

	case 11:
	exit(0);
	break;

	default:
	break;

    }
    goto Y;
}

void WRITEFILE()
{
    f.open("hotel.dat",ios::binary|ios::app);
    s.GETDATA();
    f.write((char *)&s,sizeof(s));
    f.close();
}

void ROOM::GETDATA()
{
    cout<<"Enter NAME OF GUEST \n ";
    cin.getline(name,sizeof(name));
    cin.get(ch);
    cout<<"Enter CUSTOMER ID \n";
    cin>>id;
    cout<<"Enter ROOM NO \n";
    cin>>no;
    cout<<"Enter NO OF MEMBERS  \n";
    cin>>members;
    cout<<"Enter DATE OF CHECKIN \n";
    cin>>dcheckin.dd;
    cout<<"/";
    cin>>dcheckin.mm;
    cout<<"/";
    cin>>dcheckin.yy;
    cout<<"\n";
    cout<<"Enter DATE OF CHECKOUT \n ";
     cin>>dcheckout.dd;
    cout<<"/";
    cin>>dcheckout.mm;
    cout<<"/";
    cin>>dcheckout.yy;
    cout<<"\n";
     cout<<"Enter ADDRESS \n";
     cin>>house.houseno;
     cin.getline(house.locality,sizeof(house.locality));
     cin.get(ch);
     cin.getline (house.city,sizeof(house.city));
     cin.get(ch);
}

void ROOM::PUTDATA()
{
    cout<<"Name of GUEST - "<<name<<"\n";
    cout<<"CUSTOMER ID - "<<id<<"\n";
    cout<<"ROOM NO - "<<no<<"\n";
    cout<<"No of MEMBERS - "<<members<<"\n";
    cout<<"Date of CHECKIN - "<<dcheckin.dd<<"/"<<dcheckin.mm<<"/"<<dcheckin.yy<<"\n";
    cout<<"Date of CHECKOUT - "<<dcheckout.dd<<"/"<<dcheckout.mm<<"/"<<dcheckout.yy<<"\n";
    cout<<"ADDRESS - "<<house.houseno<<","<<house.locality<<","<<house.city<<"\n";
}
void DISPLAYALL()
{   int m;
    f.open("hotel.dat",ios::binary|ios::in);
    while(f.read((char *)&s,sizeof(s)))
    s.PUTDATA();
    f.close();
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }
}
void STATUS(int i)
{
    int m;
    if(set[i].vcondition==Vacant)
    {   cout<<"ROOM - "<<i<<"\n";
	cout<<"\n This room is vacant. You can check into this room\n";
    }
    else if(set[i].vcondition==NotVacant)
    {
	cout<<"\nThis room is not vacant\n";
    set[i].id=m;
    SEARCH(m);
    }
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }
}
void CHECKIN(int i)
{
    int m;
    cout<<"Enter customer id\n";
    cin>>m;
    set[i].vcondition=NotVacant;
    set[i].scondition=Done;
    set[i].id=m;
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }
}
void CHECKOUT(int i)
{   int m;
    set[i].vcondition=Vacant;
    set[i].scondition=Pending;
    m=set[i].id;
    set[i].id=0;
    DELFILE(m);
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }

}

void DELFILE(int val)
{
    fstream f1,f2;
    f1.open("hotel.dat",ios::binary|ios::in);
    f2.open("Temp.dat",ios::binary|ios::out);
    while(f1.read((char *)&s,sizeof(s)))
    {
        if(s.retid()!=val)
        f2.write((char *)&s,sizeof(s));

    }
    f1.close();
    f2.close();
    remove("hotel.dat");
    rename("Temp.dat","hotel.dat");
}
void VACSER()
{   int i,m;
	for(i=0;i<10;i++)
    {
       if(set[i].vcondition==Vacant&&set[i].scondition==Pending)
       {cout<<"ROOM NO - "<<i<<"\n";
       cout<<"VACANCY - VACANT\n";
       cout<<"SERVICE - PENDING\n\n";
       }
       else if(set[i].vcondition==Vacant&&set[i].scondition==Done)
       {cout<<"ROOM NO - "<<i<<"\n";
       cout<<"VACANCY - VACANT\n";
       cout<<"SERVICE - DONE\n\n";}
       else if(set[i].vcondition==NotVacant&&set[i].scondition==Pending)
        {cout<<"ROOM NO - "<<i<<"\n";
       cout<<"VACANCY - NOT VACANT\n";
       cout<<"SERVICE - PENDING\n\n";}
        else if(set[i].vcondition==NotVacant&&set[i].scondition==Done)
       {cout<<"ROOM NO - "<<i<<"\n";
       cout<<"VACANCY - NOT VACANT\n";
       cout<<"SERVICE - DONE\n\n";}
    }
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }
}
void EXCHANGE(int m,int n)
{   int c;
    hotel temp;
    temp=set[m];
    set[m]=set[n];
    set[n]=temp;
    cout<<"Press 0  to go back to MAIN MENU\n";
    cin>>c;
    if(c==0)
    {
	MENU();
    }
}
int main()
{
    
    MENU();
    getch();
    return 0;
}
void SEARCH(int val)
{
    int m;
    f.open("hotel.dat",ios::binary|ios::in);
    int flag=0;
    while(f.read((char *)&s,sizeof(ROOM)))
    {
        if(s.retid()==val)
        {
            cout<<"Found\n";
            flag=1;
            s.PUTDATA();
            break;

        }
    }
    f.close();
    {
        if(flag==0)
        {
            cout<<"Record not found\n";
        }
    }
    cout<<"Press 0 to go back to MAIN MENU\n";
    cin>>m;
    if(m==0)
    {
	MENU();
    }
}

void SEARCH(char *m)
{

    int c,flag=0;
    f.open("hotel.dat",ios::binary|ios::in);
    while(f.read((char *)&s,sizeof(s)))
    {
        if(strcmp(m,s.retname())==0)
        {
            flag=1;
            cout<<"Record found\n";
            s.PUTDATA();
        }
        f.close();
        if(flag==0)
        {
            cout<<"Record not found\n";
        }
    }
    cout<<"Press 0 to go back to MAIN MENU\n";
    cin>>c;
    if(c==0)
    {
	MENU();
    }
}
void MODIFY(int a)
{   ROOM s;
    int m;

    f.open("hotel.dat",ios::binary|ios::in|ios::out);
    while(f.read((char *)&s,sizeof(s)))
    {
        if(a==s.retid())
        {
            f.seekg(-sizeof(s),ios::cur);
            cout<<"Enter new details\n";
            s.GETDATA();
            f.write((char *)&s,sizeof(s));
        }
    f.close();
    }
    cout<<"Press 0  to go back to MAIN MENU\n";
	cin>>m;
	if(m==0)
    {
	MENU();
    }
}
    
closed account (N36fSL3A)
Why are you using Turbo C++ in the first place? Go get MinGW or VC++.

Seriously, I'd rather have Dev C++

(It's a good sign its outdated when you see a standard library header with '.h' after it)
Last edited on
I don't understand this error, are you trying to link to your executable? Don't do that. Also you should get a better IDE, the fact that this one assumes you're using the std namespace without your explicitly declaring it is another bad sign.

@ Fred: The .h extension just means that the header is meant for an application written in C instead of C++. It indicates that it does not use any features that are part of the C++ standard but not the C standard.
@Computergeek01: iostream.h and fstream.h do not exist in the C standard
Last edited on
That's handy to point out to the OP, but I thought I worded that carefully enough. I said that they do not use any features that are part of the C++ but not the C standard, not that that the files themselves are part of the C standard. The example I had in mind was the WinAPI, which use '.h' to indicate what files are compatible with C.
> it does not use any features that are part of the C++ standard but not the C standard.
I have no idea how to read that.
The `but not the C standard' confuses me.

I guess that it means `it is compatible with C'
Which is false, as cout and cin use operator overloading

So, ¿do you mind to reword it?
Last edited on
Topic archived. No new replies allowed.