- Joined
- Sep 22, 2012
- Messages
- 90
right now I'm very confused about pointers,
how do i delete a specific element?
JASS:
#include <iostream>
using namespace std;
//funcs
void print(int *get,int size){
for(int i=0;i<size;i++){
cout<<"abyss["<<i<<"]: "<<get[i]<<" abyss reference: "<<&get[i]<<endl;
}
}
//=====
int main()
{
int size,del_index;
int *abyss=0,*deleter=0;
cout<<"enter size";
cin>>size;
abyss=new int[size];
for(int i=0;i<size;i++){
cout<<"enter element ["<<i<<"]: ";
cin>>abyss[i];
cout<<"reference of abyss[iter]: "<<&abyss[i]<<endl;
}
print(abyss,size);
//work around to empty an element
cout<<"delete index element: ";
cin>>del_index;
deleter=&abyss[del_index];
delete deleter;
cout<<"=========deleted=========="<<endl;
//printagain
print(abyss,size);
abyss = NULL;
system("PAUSE");
return 0;
}
how do i delete a specific element?