Dec 6, 2014 at 9:24pm UTC
hi guys ... :D
can any one tell me what's the problem in my prog. !!
while the prog. running compiler say " access violation .. "
this my code ...
sorry if iam doing some thing wrong cause it's my first time to write on a website :)
solved :
just forget to make r=NULL ; rf =NUll ; frontm=NUll; frontf=NULL ;
i will keep it may help another one
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
#include <iostream>
#include<conio>
struct stu{
int id;
float gba ;
char gender ;
stu *next ;
}*r ,*rf ;
stu read()
{stu temp ;
cout << "enter the id : \t" ;
cin>> temp.id ;
cout << "\nenter the gba : \t " ;
cin>> temp.gba ;
cout << "\nenter the gender :\t" ;
cin>> temp.gender ;
return temp ;
}
enqueue(stu x )
{stu *temp ;
temp= new stu ;
temp->id=x.id ;
temp->gba=x.gba ;
temp->gender=x.gender ;
temp->next=NULL ;
if ( (rf==NULL) && (r==NULL))
{r=temp ;
rf= temp ;
return 0 ;}
r->next = temp ;
r=temp ;
}
bool_empty()
{ if (rf==NULL) return true ;
else return false ;
}
dequeue()
{ stu * temp ;
temp = rf ;
rf = rf->next ;
cout<< "id =\t" << temp->id << "gba =\t" << temp->gba << "gender =\t" << temp->gender << "\n" ;
}
main()
{ stu *male , *female , *frontm ,*frontf ;
stu st1 ;
char c , ans ;
male=NULL ;
female =NULL ;
do
{cout<< " if the student male press (m) and (f) for female : \n" ;
cin >> c ;
if ( (c=='m' ) || (c=='M' ))
{st1=read() ;
r=male ;
rf=frontm ;
enqueue(st1) ;
male=r ;
frontm=rf ;
}
else if ((c=='f' )||(c=='F' ))
{st1=read() ;
r=female ;
rf=frontf ;
enqueue(st1) ;
female=r ;
frontf=rf ;}
else { cout<< "you have finished \n :" ; }
cout << "press (y) if there is another student : " ;
cin>>ans ;
}while ((ans== 'y' )||(ans== 'Y' )) ;
cout << " data of the male student : \n " ;
rf=frontm ;
while (bool_empty()==false )
{r= male ;
dequeue() ;
}
cout << " data of the female student : \n " ;
rf=frontf ;
while (bool_empty()==false )
{r=female ;
dequeue() ;
}
getch();
}
Last edited on Dec 7, 2014 at 8:49pm UTC
Dec 7, 2014 at 2:08pm UTC
popa6200
at first ... i am really so sorry about this mistake :)
and thanks for your help but i can't understand what are you meaning about 'could use please structure it !'
my prog. should make two queue "one for male and another for female " using linked list ,,
i tried another prog. but the same massaged show with another number " like : access violation at 0x4011e0 write of address 0x9 "
Last edited on Dec 7, 2014 at 2:34pm UTC