If make a char pointer and then create dynamically a char array of say 5 size....and then at the pressing a key i want to delete /release memory from specific index say index 2,and finally when my program ends it should delete/release memory from the remaining indexes...how is it going to be in vc++...
in the following code i tried to do this but it gives error
#include<iostream>
#include<conio.h>
using namespace std;
void main() {
char *text;
text = new char[5];
Unless your array is allocated element by element, I mean by that that it's not really an array but you have allocated 5 ints for instance you cannot do what you ask. Mainly because if you want to delete the remaining you are going to redelete some and that's not good.