[Dev-C++] elements from an array of pointers...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: senem b. <sbe...@ya...> - 2002-10-28 10:12:42
|
when i try to get the elements back from a function i wrote, i get an error called "access violation" and i don't know what that is.i'd be glad if anyone who has time would look at it...i'm sending one part of the code, the one which doesn't work...
kind regards...
int removecar(int garagenum,char *mystring){
int i=0;
char plaka[10];
if(garagenum==1){
while(strcmp(garage1.plate[i],mystring)==0){
pop(plaka,garage1);
push(plaka,temporary);
i++;
}
while(isempty(temporary)!=1){
pop(plaka,temporary);
push(plaka,garage1);
}
temp_pop(plaka,garage3);
push(plaka,garage1);
return 1;
}
if(garagenum==2){
i=0;
while(strcmp(garage2.plate[i],mystring)==1){
pop(plaka,garage2);
push(plaka,temporary);
i++;
}
while(!isempty(temporary)){
pop(plaka,temporary);
push(plaka,garage2);
}
temp_pop(plaka,garage3);
push(plaka,garage2);
return 1;
}
if(garagenum==3){
if(findel(garage1,mystring)){
while(strcmp(garage1.plate[i],mystring)==1){
pop(plaka,garage1);
push(plaka,temporary);
i++;
}
while(!isempty(temporary)){
pop(plaka,temporary);
push(plaka,garage1);
}
return 1;
}
if(findel(garage2,mystring)){
while(strcmp(garage2.plate[i],mystring)==1){
pop(plaka,garage2);
push(plaka,temporary);
i++;
}
while(!isempty(temporary)){
pop(plaka,temporary);
push(plaka,garage2);
}
return 1;
}
if(temp_findel(garage3,mystring)){
temp_pop(plaka,garage3);
return 1;
}
if(!temp_findel(garage3,mystring)&&!findel(garage2,mystring)&&
!findel(garage1,mystring))
return 0;
}
}
void pop(char *mystring,garage &line){
if(isempty(line)){
cout<<"error,can't pop,stack empty"<<endl;
exit(1);
}
else{
line.top--;
mystring=new char[sizeof(line.plate[line.top])/sizeof(char)];
strcpy(mystring,line.plate[line.top]);
line.elements--;
}
}
void temp_pop(char *mystring,temp_storage &line){
if(temp_isempty(line)){
cout<<"error,can't pop,stack empty"<<endl;
exit(1);
}
else{
line.temptop--;
mystring=new char[sizeof(line.tempplate[line.temptop])
/sizeof(char)];
strcpy(mystring,line.tempplate[line.temptop]);
line.tempelements--;
}
}
---------------------------------
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site |