Note that there are some explanatory texts on larger screens.

plurals
  1. POfile manipulation
    primarykey
    data
    text
    <p>in c++ i have written a simple program, which accepts 4 to 6 records and then do not accept any more when airline_no is same i.e. 1? The source code is:</p> <pre><code>#include&lt;fstream.h&gt; #include&lt;conio.h&gt; #include&lt;dos.h&gt; #include&lt;string.h&gt; #include&lt;stdlib.h&gt; #include&lt;process.h&gt; #include&lt;stdio.h&gt; int lno; struct airln {int airline_no,routeno,dep_time,arr_time; char port_d[15],port_a[15],week_day[10]; }r2; class route { public: void getroute() { cout&lt;&lt;"\n\tRoute no.: "; cin&gt;&gt;r2.routeno;cout&lt;&lt;"\n"; cout&lt;&lt;"\tDay of Departure: "; gets(r2.week_day);cout&lt;&lt;"\n"; cout&lt;&lt;"\tAirport for departure: "; gets(r2.port_d);cout&lt;&lt;"\t"; cout&lt;&lt;"Departure Time: "; cin&gt;&gt;r2.dep_time;cout&lt;&lt;"\n"; cout&lt;&lt;"\tAirport for arrival: "; gets(r2.port_a);cout&lt;&lt;"\t"; cout&lt;&lt;"Arrival Time: "; cin&gt;&gt;r2.arr_time;cout&lt;&lt;"\n"; cout&lt;&lt;"\n\tAirline no.: "; cin&gt;&gt;r2.airline_no; } void display_route() { cout&lt;&lt;"\n Route No : ";cout&lt;&lt;r2.routeno; cout&lt;&lt;"\n "; cout&lt;&lt;r2.port_d;cout&lt;&lt;"\t"; cout&lt;&lt;r2.dep_time;cout&lt;&lt;"\t\t"; cout&lt;&lt;r2.port_a;cout&lt;&lt;" \t"; cout&lt;&lt;r2.arr_time;cout&lt;&lt;"\t\t"; cout&lt;&lt;r2.week_day;cout&lt;&lt;"\n"; } }r3; void main() { clrscr(); int airlnno,rtnodel,cntr; char airlinename[30]; ifstream fin,fin1; ofstream fout; do { cout&lt;&lt;"\t1. Insert Data.\n"; cout&lt;&lt;"\t2. View Data.\n"; cout&lt;&lt;"\t3. Exit.\n"; cout&gt;&gt;"\tEnter Choice : ";cin&gt;&gt;cntr; switch(cntr) { case 1:r3.getroute(); fout.open("testdata.dat",ios::app); if(!fout) { gotoxy(25,10); cout&lt;&lt;"No file exists or file can\'t be opened\n"; gotoxy(25,22); cout&lt;&lt;"Please Press Any Key to Continue......."; getch(); clrscr(); } fout.write((char *) &amp;r2,sizeof(r2)); fout.close(); clrscr(); break; case 2:fin.open("testdata.dat",ios::in); if(!fin) { gotoxy(25,20); cout&lt;&lt;"No file exists or file can\'t be opened\n"; gotoxy(25,22); cout&lt;&lt;"Please Press Any Key to Continue......."; getch(); clrscr(); break; } cout&lt;&lt;"\n Dep-Airport\t"; cout&lt;&lt;"Dep-Time\t"; cout&lt;&lt;"Arr-Airport\t"; cout&lt;&lt;"Arr-Time\t"; cout&lt;&lt;"Week Day\n"; fin.read((char *) &amp;r2,sizeof(r2)); while(!fin.eof()) { r3.display_route(); fin.read((char *) &amp;r2,sizeof(r2)); } fin.close(); gotoxy(25,22); cout&lt;&lt;"Please Press Any Key to Continue......."; getch(); clrscr(); } } while(!(cntr==3)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload