i'm getting this error in turbo c++, how to rectify it?

Thread stopped
D:\Users\HOME\Desktop\cpp iaf
project\CPP PROJECT.exe: Fault:
access violation at 0x402a5e: read of
address 0x0

in the following program:
though the program is incomplete ,but with 0 (no) errors it is giving this strange error.
i'm unable to upload the program code due to its excessive length.
please tell me why this error comes and how to rectify it.

THANKS IN ADVANCE.
There is simply no way anyone can help without seeing your code.
Turbo C++ is over six years old, you may want to familiarize yourself with a more modern compiler (unless some professor is requiring you to use it, in which case I am very sorry for your loss).
memory address 0x0 is for OS.
ring 3, user level, program shouldn't access to that location.

if you have a pointer, having a value of 0, and try to access it, this runtime error might arise.

such as..
1
2
char * ptr = 0;
printf("%s",ptr);

will cause access violation at 0x????????: read of address of 0x00000000
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
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
//-----------------------------------------------------------------------------

  class aircraft
  {
     public:

       int long tail_no;
       int flying_hours;
       int no_of_seats;
       char aircraft_name[20],base[20],pilot_name[20],copilot_name[20],pilot_rank[10],copilot_rank[10],armaments[10][20];
       int  qty[10], temp_qty;
       aircraft();
       void enter_aircraftdet();
       void get_aircraftdet();
  };

  aircraft::aircraft()
       {
           strcpy(aircraft_name,'\0');
           no_of_seats=2;
           flying_hours=0;
           strcpy(base,'\0');
           strcpy(pilot_name,'\0');
           strcpy(pilot_rank,'\0');
           strcpy(copilot_name,'\0');
           strcpy(copilot_rank,'\0');
           strcpy(armaments[10],'\0');
       }

  void aircraft::enter_aircraftdet()
       {
           int i=0;
           cout<<"\n Enter Aircraft Name : ";                   gets(aircraft_name);
           cout<<"\n Enter Tail No. : ";                        cin>>tail_no;
           cout<<"\n Enter The Base Name : ";                   gets(base);
           cout<<"\n Enter Flying Hours : ";                    cin>>flying_hours;
           cout<<"\n Enter Number Of Seats (1 or 2) : ";        cin>>no_of_seats;
           cout<<"\n Enter Pilot's Name (Name or Type \"NULL\" If Not Assigned): ";      cin>>pilot_name;
           cout<<"\n Enter Pilot's Rank (Rank or Type \"NULL\" If Pilot Not Assigned): ";       cin>>pilot_rank;
           cout<<"\n Enter Co-Pilot's Name (Name or Type \"NULL\" If Not Assigned): ";   cin>>copilot_name;
           cout<<"\n Enter Co-Pilot's Rank (Rank or Type \"NULL\" If Co-Pilot Not Assigned): "; cin>>copilot_rank;
           for(int arm=0;arm<10;arm+=temp_qty)
           {
               cout<<"\n Enter The Armaments (Maximum 10): ";   cin>>armaments[arm];
               cout<<"\n Enter Quantity Of Entered Weapon ";    cin>>temp_qty;
               qty[i]=temp_qty;
               i++;
           }
		 }
  void aircraft::get_aircraftdet()
       {
           int i=0;
           cout<<"\n Aircraft Name : ";                         puts(aircraft_name);
           cout<<"\n Tail No. : ";                              cout<<tail_no;
           cout<<"\n Base Name : ";                             gets(base);
           cout<<"\n Flying Hours : ";                          cout<<flying_hours;
           cout<<"\n Pilot's Name ( NULL If Not Assigned): ";      cout<<pilot_name;
           cout<<"\n Pilot's Rank ( NULL If Pilot Not Assigned): ";         cout<<pilot_rank;
           cout<<"\n Co-Pilot's Name ( NULL If Not Assigned): ";   cout<<copilot_name;
           cout<<"\n Co-Pilot's Rank ( NULL If Co-Pilot Not Assigned): ";   cout<<copilot_rank;
          for(int arm=0;arm<10;arm+=qty[i])
           {
               cout<<"\n WEAPON \t\t\t\t QUANTITY\n  ";
               cout<<armaments[arm]<<" \t\t\t\t "<<qty[i];
               i++;
           }
       }
//-----------------------------------------------------------------------------

  class pilot
  {
     public:

       char pilots_name[20],  pilots_rank[20], pilots_squadron[20], base[20];
       int flying_hours, aircraft_assigned;
       double salary;

       void enter_pilotdet();
       void get_pilotdet();
  };


  void pilot::enter_pilotdet()
       {
           cout<<"\n Enter Pilot Name : ";                      gets(pilots_name);
           cout<<"\n Enter Rank : ";                            gets(pilots_rank);
           cout<<"\n Enter The Base Name : ";                   gets(base);
           cout<<"\n Enter Flying Hours : ";                    cin>>flying_hours;
           cout<<"\n Enter Assigned Aircraft's Tail No. (No. or Type 0 If Not Assigned): ";  cin>>aircraft_assigned;
           cout<<"\n Enter Salary : ";                          cin>>salary;
		 }
  void pilot::get_pilotdet()
       {
           cout<<"\n Pilot Name : ";                      puts(pilots_name);
           cout<<"\n Rank : ";                            puts(pilots_rank);
           cout<<"\n The Base Name : ";                   puts(base);
           cout<<"\n Flying Hours : ";                    cout<<flying_hours;
           cout<<"\n Assigned Aircraft's Tail No. (0 If Not Assigned): ";  cout<<aircraft_assigned;
           cout<<"\n Salary : ";                          cout<<salary;
       }


//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
  void main()
 {   int choice;
     aircraft plane;
     pilot officer;
     again:
     cout<<"\n\t\t\t*** WELCOME TO INDIAN AIR FORCE PAGE ***";
     cout<<"\n Please Enter Your Task";
     cout<<"\n \t \a1). ADMINISTRATOR ";
     cout<<"\n \t 2). ASSIGN PILOTS TO AIRCRAFTS";
     cout<<"\n \t 3). ASSIGN AIRCRAFT TO A PILOT";
     cout<<"\n \t 4). SEARCH FOR AN AIRCRAFT";
     cout<<"\n \t 5). SEARCH FOR A PILOT";
     cout<<"\n Enter Your Choice Here (1,2,3,4 or 5):";
     cin>>choice; cout<<'\a';
     clrscr;

//******************************************************************************

     if(choice==1)
     {
         cout<<"\n Select Your Task";
         cout<<"\n \t1). ADD NEW AIRCRAFT DETAILS";
         cout<<"\n \t2). ADD NEW PILOT DETAILS";
         cout<<"\n \t3). EDIT AIRCAFT DETAILS ";
         cout<<"\n \t4). EDIT PILOT DETAILS";
         cout<<"\n \t5). PROMOTE A PILOT";

     if(choice==1)
     {
           plane.enter_aircraftdet();
           ofstream aircraftfile;
           aircraftfile.open("aircraftfile.dat",ios::ate||ios::binary);
           aircraftfile.write((char*)&plane,sizeof(plane));
           aircraftfile.close();
     }                                          

     if(choice==2)
     {                               
           officer.enter_pilotdet();
           ofstream pilotfile;
           pilotfile.open("pilotfile.dat",ios::ate||ios::binary);
           pilotfile.write((char*) &officer,sizeof(officer));
           pilotfile.close();
     }

     if(choice==3)
     {
            int q=-1;
           fstream aircraftfile;

           aircraftfile.open("aircraftfile.dat",ios::app||ios::in||ios::binary);

           int tno;
           cout<<"\n Enter The Aircraft's Tail Number To Be Assigned Pilot(s) :";        cin>>tno;
           while(!aircraftfile.eof())
           {
                aircraftfile.read((char*) &plane,sizeof(plane));
                if(tno==plane.tail_no)
                {
                  q++;
                  break;
                }
           };

           if(q==-1)
           {
                cout<<"\n Sorry, Aircraft Not Found.";
           }
              else
           {
                cout<<"\n Aircraft Found!";




      		     aircraftfile.write((char*) &plane,sizeof(plane));



     		      }
    		       aircraftfile.close();

     }

     if(choice==4)
     {

     }

     if(choice==5)
     {

     }

     if(choice>5)
     {

     }

     }
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
//******************************************************************************

     if(choice==2)
     {
           int q=-1;
           fstream aircraftfile;
           fstream pilotfile;
           aircraftfile.open("aircraftfile.dat",ios::app||ios::in||ios::binary);
           pilotfile.open("pilotfile.dat",ios::app||ios::in||ios::binary);

           int tno;
           cout<<"\n Enter The Aircraft's Tail Number To Be Assigned Pilot(s) :";        cin>>tno;
           while(!aircraftfile.eof())
           {
                aircraftfile.read((char*) &plane,sizeof(plane));
                if(tno==plane.tail_no)
                {
                  q++;
                  break;
                }
           };
           cout<<"\n Aircraft Found!";
           if(strcmp(plane.pilot_name,"NULL")==0)
           {
                 cout<<"\n Enter Pilot's Name";                       gets(plane.pilot_name);
                 cout<<"\n Enter Pilot's Rank";                       gets(plane.pilot_rank);
           }
           if(plane.no_of_seats==2)
           {
                 if(strcmp(plane.copilot_name,"NULL")==0)
                 {
                       cout<<"\n Enter Co-Pilot's Name";                       gets(plane.copilot_name);
                       cout<<"\n Enter Co-Pilot's Rank";                       gets(plane.copilot_rank);
                 }
           }

           aircraftfile.write((char*) &plane,sizeof(plane));

           while(!pilotfile.eof())
           {
                 pilotfile.read((char*) &officer,sizeof(officer));
                 if(strcmp(officer.pilots_name,plane.pilot_name)==0||strcmp(officer.pilots_name,plane.copilot_name)==0)
                 {
                          officer.aircraft_assigned=tno;
                          pilotfile.write((char*) &officer,sizeof(officer));
                 }
           };
           aircraftfile.close();
           pilotfile.close();
     }

//******************************************************************************

     if(choice==3)
     {
           int q=-1;
           fstream aircraftfile;
           fstream pilotfile;
           aircraftfile.open("aircraftfile.dat",ios::app||ios::in||ios::binary);
           pilotfile.open("pilotfile.dat",ios::app||ios::in||ios::binary);
           int subcat;
           char name[20];
           cout<<"\n \tDO YOU WANT TO ASSIGN ";
           cout<<"\n \t\t1). PILOT";
           cout<<"\n \t\t2). CO-PILOT";
           cin>>subcat;
           cout<<"\n Enter The Name Of The Pilot To Be Assigned Aircraft :";        gets(name);
           while(!pilotfile.eof())
           {
                pilotfile.read((char*) &officer,sizeof(officer));
                if(strcmp(officer.pilots_name,name)==0)
                {
                  q++;
                  break;
                }
           };

           if(q==-1)
           {
               cout<<"\n Pilot Not Found";
           }
                else
           {

              cout<<"\n Pilot Found!";

           if(plane.tail_no==0)
           {
                 cout<<"\n Enter Aircraft's Tail Number";                       cin>>officer.aircraft_assigned;
           }

           pilotfile.write((char*) &officer,sizeof(officer));

           while(!aircraftfile.eof())
           {
                 aircraftfile.read((char*) &officer,sizeof(officer));
                 if(officer.aircraft_assigned==plane.tail_no)
                 {
                       if(subcat==1)
                       {
                            strcpy(plane.pilot_name,officer.pilots_name);
                       }
                       if(subcat==2)
                       {
                            strcpy(plane.copilot_name,officer.pilots_name);
                       }
                       aircraftfile.write((char*) &officer,sizeof(officer));
                 }
           };
           }
           aircraftfile.close();
           pilotfile.close();
     }

//******************************************************************************

     if(choice==4)
     {
           int q=-1;
           fstream aircraftfile;
           fstream pilotfile;
           aircraftfile.open("aircraftfile.dat",ios::app||ios::in||ios::binary);
           pilotfile.open("pilotfile.dat",ios::app||ios::in||ios::binary);
           char pname[20];
           cout<<"\n Please Enter The Pilot's Name To Be Promoted";                gets(pname);
           while(!pilotfile.eof())
           {
                pilotfile.read((char*) &officer,sizeof(officer));
                if(strcmp(officer.pilots_name,pname)==0)
                {
                  q++;
                  break;
                }
           };
           cout<<"\n Pilot Found!";

     }

//******************************************************************************

     if(choice==1000)
     {

     }

//******************************************************************************

     if(choice>1000)
     {
          cout<<"\n \t INCORRECT CHOICE!!! PLEASE TRY AGAIN!!!";
          goto again;
     }

//******************************************************************************

     cout<<"\n DO YOU WANT TO DO ANOTHER TASK??";
     cout<<"\n \t 1). GO TO MAIN MENU";
     cout<<"\n \t 2). EXIT";
     cout<<"\n Enter Your Choice Here (1 or 2):";
     cin>>choice;

     if(choice==1)
     {
         goto again;
     }

     if(choice==2)
     {
        cout<<'\a';
        cout<<"\n \t**GOOD BYE**";
        exit(1);
     }

//******************************************************************************

     getch();
 }
here is the program.
strcpy(base,'\0');
This is what's crashing your program.

All those char arrays can be intialised as:
base[0] = 0;
or
strcpy(base, "");
it worked!!

thanks a lot kbw. :)
Topic archived. No new replies allowed.