im doing a college project in c++. it is a token system of bank(line,queue..).it waits for a enter key and then it creates a token with entry time and expected leaving time,cashier to attend to and token no. whenever i compile the program it gives no error but after runing it stops and i get an error saying general protection exception processor fault...it stops at a structure pointer to a time variable..plzzzz help,i have to submit this tomorrow thnaks for help in advance and thanks daniweb.heres my code

#include<conio.h>
#include<iostream.h>
#include<time.h>
#include<windows.h>
#include<stdlib.h>
struct cashier{
time_t endtime;
//cashier c[3];
}*c11,*c22,*c33;//c[0]->endtime=time(),c[1]->endtime=time(),c[2]->endtime=tme(),c[3]->endtime=time();

struct node{
node *next;
int job;
int cashierno,tokenno;
time_t entertime,exittime;
}*c1=NULL,*c2=NULL,*c3=NULL,*l,*temp;

void check();
void print();
int first_cashier();
void newenter();
time_t currenttime,starttime;
int ctr=1;

void main()
{
clrscr();
cout<<"press E to end anytime";
starttime=time(NULL);
c11->endtime=starttime;
c22->endtime=starttime;
c33->endtime=starttime;
currenttime=time(NULL);
while(1)
	{
	if(GetKeyState(13)==1)
		newenter();
	else if(GetKeyState(101)==1)
		goto end;
	check();
	print();
	while(time(NULL)-currenttime<1)
	{}
	currenttime++;
	}
end:
getch();
}

void newenter()
{
int i,jobb;
clrscr();
cout<<"what do you want to do?\n1-WITHDRAW\n2-DEPOSIT\n";
jobb=getche();
i=first_cashier();
if(i==1)
	{
	l=c1;
	if(l==NULL)
		{
		c1=new(node);
		c1->cashierno=i;
		c1->entertime=currenttime;
		if(jobb==1)
		 {
		 c1->exittime=c11->endtime+120;
		 c1->job=1;//"WITHDRAW";
		 }
		else if(jobb==2)
		 {
		 c1->exittime=c11->endtime+60;
		 c1->job=2;//"DEPOSIT";
		 }
		c11->endtime=c1->exittime;
		c1->tokenno=ctr;
		c1->next=NULL;
		}
	else
		{
		while(l->next!=NULL)
			l=l->next;
		}
	temp=new(node);
	temp->cashierno=i;
	temp->entertime=currenttime;
	if(jobb==1)
		{
		temp->exittime=c11->endtime+120;
		temp->job=1;//"WITHDRAW";
		}
	else if(jobb==2)
		{
		temp->exittime=c11->endtime+60;
		temp->job=2;//"DEPOSIT";
		}
	c11->endtime=temp->exittime;
	temp->tokenno=ctr;
	temp->next=NULL;
	l->next=temp;
	}
if(i==2)
	{
	l=c2;
	if(l==NULL)
		{
		c2=new(node);
		c2->cashierno=i;
		c2->entertime=currenttime;
		if(jobb==1)
		 {
		 c2->exittime=c22->endtime+120;
		 c2->job=1;//"WITHDRAW";
		 }
		else if(jobb==2)
		 {
		 c2->exittime=c22->endtime+60;
		 c2->job=2;//"DEPOSIT";
		 }
		c22->endtime=c2->exittime;
		c2->tokenno=ctr;
		c2->next=NULL;
		}
	else
		{
		while(l->next!=NULL)
			l=l->next;
		}
	temp=new(node);
	temp->cashierno=i;
	temp->entertime=currenttime;
	if(jobb==1)
		{
		temp->exittime=c22->endtime+120;
		temp->job=1;//"WITHDRAW";
		}
	else if(jobb==2)
		{
		temp->exittime=c22->endtime+60;
		temp->job=2;//"DEPOSIT";
		}
	c22->endtime=temp->exittime;
	temp->tokenno=ctr;
	temp->next=NULL;
	l->next=temp;
	}
if(i==3)
	{
	l=c3;
	if(l==NULL)
		{
		c3=new(node);
		c3->cashierno=i;
		c3->entertime=currenttime;
		if(jobb==1)
		 {
		 c3->exittime=c33->endtime+120;
		 c3->job=1;//"WITHDRAW";
		 }
		else if(jobb==2)
		 {
		 c3->exittime=c33->endtime+60;
		 c3->job=2;//"DEPOSIT";
		 }
		c33->endtime=c3->exittime;
		c3->tokenno=ctr;
		c3->next=NULL;
		}
	else
		{
		while(l->next!=NULL)
			l=l->next;
		}
	temp=new(node);
	temp->cashierno=i;
	temp->entertime=currenttime;
	if(jobb==1)
		{
		temp->exittime=c33->endtime+120;
		temp->job=1;//"WITHDRAW";
		}
	else if(jobb==2)
		{
		temp->exittime=c33->endtime+60;
		temp->job=2;//"DEPOSIT";
		}
	c33->endtime=temp->exittime;
	temp->tokenno=ctr;
	temp->next=NULL;
	l->next=temp;
	}
currenttime=time(NULL);
ctr++;
}


int first_cashier()
{
if(c11->endtime<c22->endtime&&c11->endtime<c33->endtime)
	return 1;
else if(c22->endtime<c11->endtime&&c22->endtime<c33->endtime)
	return 2;
else if(c33->endtime<c22->endtime&&c33->endtime<c22->endtime)
	return 3;
else
	return 1;
}


void print()
{
int x,y;
clrscr();
cout<<localtime(&currenttime)->tm_hour<<":"<<localtime(&currenttime)->tm_min<<":"<<localtime(&currenttime)->tm_sec<<"\n\n";
cout<<"CASHIER#1\n";
l=c1;
while(l->next!=NULL)
	{
	cout<<"token#"<<l->tokenno<<endl;
	cout<<"cashier#"<<l->cashierno<<endl;
	cout<<l->job<<endl;
	cout<<"entery time "<<localtime(&l->entertime)->tm_hour<<":"<<localtime(&l->entertime)->tm_min<<":"<<localtime(&l->entertime)->tm_sec<<endl;
	cout<<"exit time "<<localtime(&l->exittime)->tm_hour<<":"<<localtime(&l->exittime)->tm_min<<":"<<localtime(&l->exittime)->tm_sec<<endl;
	cout<<"________________"<<endl;
	l=l->next;
	}
x=30;y=2;
gotoxy(x,y);
cout<<"CASHIER#2";y++;
l=c2;
while(l->next!=NULL)
	{
	gotoxy(x,y);
	cout<<"token#"<<l->tokenno;y++;
	gotoxy(x,y);
	cout<<"cashier#"<<l->cashierno;y++;
	gotoxy(x,y);
	cout<<l->job;y++;
	gotoxy(x,y);
	cout<<"entery time "<<localtime(&l->entertime)->tm_hour<<":"<<localtime(&l->entertime)->tm_min<<":"<<localtime(&l->entertime)->tm_sec;y++;
	gotoxy(x,y);
	cout<<"exit time "<<localtime(&l->exittime)->tm_hour<<":"<<localtime(&l->exittime)->tm_min<<":"<<localtime(&l->exittime)->tm_sec;y++;
	gotoxy(x,y);
	cout<<"________________";y++;
	l=l->next;
	}
x=60;y=2;
gotoxy(x,y);
cout<<"CASHIER#3";y++;
l=c3;
while(l->next!=NULL)
	{
	gotoxy(x,y);
	cout<<"token#"<<l->tokenno;y++;
	gotoxy(x,y);
	cout<<"cashier#"<<l->cashierno;y++;
	gotoxy(x,y);
	cout<<l->job;y++;
	gotoxy(x,y);
	cout<<"entery time "<<localtime(&l->entertime)->tm_hour<<":"<<localtime(&l->entertime)->tm_min<<":"<<localtime(&l->entertime)->tm_sec;y++;
	gotoxy(x,y);
	cout<<"exit time "<<localtime(&l->exittime)->tm_hour<<":"<<localtime(&l->exittime)->tm_min<<":"<<localtime(&l->exittime)->tm_sec;y++;
	gotoxy(x,y);
	cout<<"________________";y++;
	l=l->next;
	}
}


void check()
{
if(c1->exittime>currenttime)
	{
	l=c1;
	c1=l->next;
	//del(l);
	}
if(c2->exittime>currenttime)
	{
	l=c2;
	c2=l->next;
	//del(l);
	}
if(c3->exittime>currenttime)
	{
	l=c3;
	c3=l->next;
	//del(l);
	}
}

help people plzzz..im using winodws xp and tc 4.5

I have not made any further tests but...

c11, c22 and c33 are pointers to cashier-structs (line 9).

In line 30-32 you use the indirection-operator (->) to access the cashier instances pointed to, but you never created the cashier instances. c11, c22 and c33 are pointing to some random memory.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.