V.clear ()command not working

#include
#include
#include
using namespace std;
int main() {
vectorv;
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int temp;
cin>>temp;
v.push_back(temp);
}
v.clear();

for(int i=0;i<n;i++)
{
    cout<<v[i]<<endl;
}

}

Hi bhavit
The memory location is not deleted by clear(). However there is no element present in context with vector.
You can check by:
for(auto it=v.begin();it!=v.end();it++){
cout<<*it<<endl;
}
It return nothing.

Hope it helps:)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.