| Цитата | А что в товоем коде надо сделать?
|
в моем коде....туда надо просто добавить вот то что ты написал....: departure_of_buses, entrance_of_buses, buses_on_a_route_and_in_garage, inquiry_about_departure....и правильно их всех вызвать.....
Добавлено @ 19:37 я вот тут добавила....вылезает 8 ошибок....но там они все одинаковые....посторяется 4 раза одни и те же две ошибки....и 4 предупреждения....
| Код | #include<stdio.h> #include<string.h> #include<iostream.h> #include<fcntl.h> #include<io.h> #include<sys\stat.h>
#include<stdlib.h>
enum bool{ false, true };
struct scan_info { char FIO_voditel[ 50 ], bus_place[ 25 ]; int bus_number, route_number; };
bool checkavail( int handle ) { if ( filelength(handle)==0 ) { printf( "Sperva nado vvesti dannie!\n" ); system( "pause" ); return false; } return true; }
int filled( int handle ) { int i, size; lseek( handle, 0L, SEEK_SET ); read( handle, (void*)&size, 2 );
scan_info *data; data=( scan_info * ) malloc ( sizeof(scan_info) );
for( i=0; i<size; ++i ) { system( "cls" ); printf( " --- %d --- \n", i+1 );
printf( "Nomer abtobusa : " ); scanf( "%d", &data->bus_number );
printf( "Familia i iniciali voditelaiя: " ); fgets( data->FIO_voditel, 50, stdin );
printf( "Nomer marshrutaя: " ); scanf( "%d", &data->route_number );
printf( "Gge naxoditsai abtobus (na marsrute / v parke) : " ); fgets( data->bus_place, 25, stdin );
write( handle, (void*)data, sizeof(scan_info) ); memset( data, 0, sizeof(scan_info) ); }
printf( "Gotovo !\n" ); system( "pause" ); free( data ); return 0; }
int printall( int handle ) { int size, i; FILE *TXT; TXT=fopen( ".\\USERDAT.TXT", "w+" ); if( !TXT) { perror( "Error: " ); return -1; }
lseek( handle, 0L, SEEK_SET ); read( handle, (void*)&size, 2 );
scan_info *data; data=( scan_info * ) malloc ( sizeof(scan_info) );
fseek( TXT, 0L, SEEK_SET ); for( i=0; i<size; ++i ) { read( handle, (void*)data, sizeof(scan_info) );
fprintf( TXT, "Nomer avtobusa %s\n\ Familia i iniciali voditelai %d\n\ Nomer marshruta %d\n\ Gge naxoditsai abtobus (na marsrute / v parke) %d\n\ ---------------------\n", data->bus_number, data->FIO_voditel, data->route_number, data->bus_place ); memset( data, 0, sizeof(scan_info) ); }
printf( "Gotovo!\n" ); system( "pause" ); free( data ); fclose( TXT ); return 0; }
void departure_of_buses(int handle){ iter = list_SF.begin(); cout<<"Enter numbers of buses which have gone away from garage:" <<endl; cout<<"Enter 0 for the ending:" <<endl; int i=1, ran_num_bus, j, yes;
while (i!=0){ yes=0; iter=list_SF.begin(); cout<<"Number bus:"; cin>>ran_num_bus; for(j=0; j<list_SF.size(); j++){ if(ran_num_bus==iter->bus_number) { iter->where=1; yes=1; break; } iter++; } if(!yes) cout<<"Or the dispatcher has left from mind, or such bus is not present:"<<endl;; cout<<"To continue? 1-YES, 0- NO:"; cin>>i; } system( "cls" ); } void entrance_of_buses(int handle){ iter = list_SF.begin(); cout<<"Enter numbers of buses which entrance in to garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int i=1, ran_num_bus, j, yes;
while (i!=0){ yes=0; iter=list_SF.begin(); cout<<"Number bus:"; cin>>ran_num_bus; for(j=0; j<list_SF.size(); j++){ if(ran_num_bus==iter->bus_number) { iter->where=0; yes=1; break;} iter++; } if(!yes) cout<<"Or the dispatcher has left from mind, or such bus is not present: "<<endl;; cout<<"To continue? 1-YES, 0- NO:"; cin>>i; } system( "cls" ); };
void buses_on_a_route_and_in_garage(int handle, int yes){
iter = list_SF.begin(); if(yes){ cout<<"Enter numbers of buses which have gone away from garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int j;
for(j=0; j<list_SF.size(); j++) { if(iter->where) { cout<<"The bus with number "<< iter->bus_number << " is on a route"<<endl; } iter++; } }else{ cout<<"Enter numbers of buses which have driven in garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int j;
for(j=0; j<list_SF.size(); j++) { if(!iter->where) { cout<<"The bus with number "<< iter->bus_number << " is in garage"<<endl; } iter++; } }
system( "cls" ); };
void inquiry_about_departure(int handle){
iter = list_SF.begin(); int j=1, i, ran, yes;
while(j) { yes=0; cout<<"Enter number of the bus: "; for(iter=list_SF.begin(); iter!=list_SF.end(); iter++){ cin>>ran; if(ran==iter->bus_number) {yes=1; break;} }
if(!yes) {cout<<"Or the dispatcher has left from mind, or such bus is not present";} if(yes && iter->where) //Если такой автобус существует и если он на маршруте { cout<<"The bus with number "<< iter->bus_number << " is on a route"<<endl; }else if(yes && !iter->where) //Если такой автобус существует и если он в гараже { cout<<"The bus with number"<< iter->bus_number << " is in garage"<<endl; }
system("cls"); cout<<"To continue? 1-YES, 0- NO:"; cin>>j; }
};
void main(void) { int handle, i, j, size=0, pos;
handle=open( ".\\DUMMY.DAT", O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE ); if( handle==-1 ) { perror( "Error: " ); return; }
for( i=0; i!=5 ; ) { system( "cls" ); printf( "\n\nDeistviaя:\n\ 1. Zapolnit struktyrs\n\ 2. Vivesti vse v fail dlai chtenia\n\ 3. Vivesti viborochno v fail dlai chtenia\n\ 4. Zamenit\n\ 5. Exit\n"); scanf( "%d", &i);
switch( i ) { case 1:
for( ; size<=0 || size>20; ) { system( "cls" ); printf( "%s\nKolichestvo struktyr N gde( 0<N<20 ): ", ( size>20 || size<0 ) ? "Ошибка!" : "" ); scanf( "%d", &size ); }
lseek( handle, 0L, SEEK_SET ); write( handle, (void*)&size, 2 ); filled( handle ); break;
case 2: if ( checkavail(handle) ) printall( handle ); break;
}
close( handle ); return; } }
|
Добавлено @ 19:42 вернее вот так:
| Код | #include<stdio.h> #include<string.h> #include<iostream.h> #include<fcntl.h> #include<io.h> #include<sys\stat.h>
#include<stdlib.h>
enum bool{ false, true };
struct scan_info { char FIO_voditel[ 50 ], bus_place[ 25 ]; int bus_number, route_number; };
bool checkavail( int handle ) { if ( filelength(handle)==0 ) { printf( "Sperva nado vvesti dannie!\n" ); system( "pause" ); return false; } return true; }
int filled( int handle ) { int i, size; lseek( handle, 0L, SEEK_SET ); read( handle, (void*)&size, 2 );
scan_info *data; data=( scan_info * ) malloc ( sizeof(scan_info) );
for( i=0; i<size; ++i ) { system( "cls" ); printf( " --- %d --- \n", i+1 );
printf( "Nomer abtobusa : " ); scanf( "%d", &data->bus_number );
printf( "Familia i iniciali voditelaiя: " ); fgets( data->FIO_voditel, 50, stdin );
printf( "Nomer marshrutaя: " ); scanf( "%d", &data->route_number );
printf( "Gge naxoditsai abtobus (na marsrute / v parke) : " ); fgets( data->bus_place, 25, stdin );
write( handle, (void*)data, sizeof(scan_info) ); memset( data, 0, sizeof(scan_info) ); }
printf( "Gotovo !\n" ); system( "pause" ); free( data ); return 0; }
int printall( int handle ) { int size, i; FILE *TXT; TXT=fopen( ".\\USERDAT.TXT", "w+" ); if( !TXT) { perror( "Error: " ); return -1; }
lseek( handle, 0L, SEEK_SET ); read( handle, (void*)&size, 2 );
scan_info *data; data=( scan_info * ) malloc ( sizeof(scan_info) );
fseek( TXT, 0L, SEEK_SET ); for( i=0; i<size; ++i ) { read( handle, (void*)data, sizeof(scan_info) );
fprintf( TXT, "Nomer avtobusa %s\n\ Familia i iniciali voditelai %d\n\ Nomer marshruta %d\n\ Gge naxoditsai abtobus (na marsrute / v parke) %d\n\ ---------------------\n", data->bus_number, data->FIO_voditel, data->route_number, data->bus_place ); memset( data, 0, sizeof(scan_info) ); }
printf( "Gotovo!\n" ); system( "pause" ); free( data ); fclose( TXT ); return 0; }
void departure_of_buses(int handle){ iter = list_SF.begin(); cout<<"Enter numbers of buses which have gone away from garage:" <<endl; cout<<"Enter 0 for the ending:" <<endl; int i=1, ran_num_bus, j, yes;
while (i!=0){ yes=0; iter=list_SF.begin(); cout<<"Number bus:"; cin>>ran_num_bus; for(j=0; j<list_SF.size(); j++){ if(ran_num_bus==iter->bus_number) { iter->where=1; yes=1; break; } iter++; } if(!yes) cout<<"Or the dispatcher has left from mind, or such bus is not present:"<<endl;; cout<<"To continue? 1-YES, 0- NO:"; cin>>i; } system( "cls" ); } void entrance_of_buses(int handle){ iter = list_SF.begin(); cout<<"Enter numbers of buses which entrance in to garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int i=1, ran_num_bus, j, yes;
while (i!=0){ yes=0; iter=list_SF.begin(); cout<<"Number bus:"; cin>>ran_num_bus; for(j=0; j<list_SF.size(); j++){ if(ran_num_bus==iter->bus_number) { iter->where=0; yes=1; break;} iter++; } if(!yes) cout<<"Or the dispatcher has left from mind, or such bus is not present: "<<endl;; cout<<"To continue? 1-YES, 0- NO:"; cin>>i; } system( "cls" ); };
void buses_on_a_route_and_in_garage(int handle, int yes){
iter = list_SF.begin(); if(yes){ cout<<"Enter numbers of buses which have gone away from garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int j;
for(j=0; j<list_SF.size(); j++) { if(iter->where) { cout<<"The bus with number "<< iter->bus_number << " is on a route"<<endl; } iter++; } }else{ cout<<"Enter numbers of buses which have driven in garage"<<endl; cout<<"Enter 0 for the ending:" <<endl; int j;
for(j=0; j<list_SF.size(); j++) { if(!iter->where) { cout<<"The bus with number "<< iter->bus_number << " is in garage"<<endl; } iter++; } }
system( "cls" ); };
void inquiry_about_departure(int handle){
iter = list_SF.begin(); int j=1, i, ran, yes;
while(j) { yes=0; cout<<"Enter number of the bus: "; for(iter=list_SF.begin(); iter!=list_SF.end(); iter++){ cin>>ran; if(ran==iter->bus_number) {yes=1; break;} }
if(!yes) {cout<<"Or the dispatcher has left from mind, or such bus is not present";} if(yes && iter->where) //Если такой автобус существует и если он на маршруте { cout<<"The bus with number "<< iter->bus_number << " is on a route"<<endl; }else if(yes && !iter->where) //Если такой автобус существует и если он в гараже { cout<<"The bus with number"<< iter->bus_number << " is in garage"<<endl; }
system("cls"); cout<<"To continue? 1-YES, 0- NO:"; cin>>j; }
};
void main(void) { int handle, i, j, size=0, pos;
handle=open( ".\\DUMMY.DAT", O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE ); if( handle==-1 ) { perror( "Error: " ); return; }
for( i=0; i!=5 ; ) { system( "cls" ); printf( "\n\nDeistviaя:\n\ 1. Zapolnit struktyrs\n\ 2. Vivesti vse v fail dlai chtenia i na ekran v tablice\n\ 3. Rabota c viezdom i v'ezdom abtobusov\n\ 4. Zaprosit dannie ob abtobuse\n\ 5. Exit\n"); scanf( "%d", &i);
switch( i ) { case 1:
for( ; size<=0 || size>20; ) { system( "cls" ); printf( "%s\nKolichestvo struktyr N gde( 0<N<20 ): ", ( size>20 || size<0 ) ? "Ошибка!" : "" ); scanf( "%d", &size ); }
lseek( handle, 0L, SEEK_SET ); write( handle, (void*)&size, 2 ); filled( handle ); break;
case 2: if ( checkavail(handle) ) printall( handle ); break;
case 3: { departure_of_buses( handle ); break; }
case 4: { buses_on_a_route_and_in_garage( handle ); break; }
case 5: { break; }
}
close( handle ); return; } }
|
одинаковые ошибки вылезают в строчках типа : iter = list_SF.begin();
что с ними сделать?....как заменить? |