Hello all! This code is an implementation of contiguous lists, in the main(), I always get the message "List is full",
what should I do?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
constint Long=100;
struct List{
int e[Long];
int last;
};
Liste L;
//p is for position
void insertion(int x, int p, Liste &L){
if(L.last>Long-1 ) cout <<"List is Full\n";
elseif (p<0 || p>L.last+1) cout <<"P incorrect\n";
else {
for( int i=L.last; i>p; i--) L.e[i+1]=L.e[i];
L.last--;
}
in the main:
1 2 3 4 5 6 7
int main(){
List L;
// however i don't know how to initialize L.der??
//I Know that L.der will start at -1, since it's empty,
insertion(10,0,L);
}
2) You haven't shown us enough code to know what might be happening inside the call to insertion(). In particular, you haven't shown us what the state of L is when you pass it into the function.