Multiple choice technology security

In the following code snippet, how should a pointer be deleted

int main (int argc, char *argv[]) { 
    char* j=new char[100];  
    j=argv[1];  
    int k=atoi(j);  
    /*delete here*/  
    return 0; 
}

  1. delete j

  2. free j

  3. it is not supposed to be deleted

  4. delete [] j

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

j is allocated with new char[100](array form), then immediately overwritten with argv[1], leaking the allocated memory. At the delete point, j points to the command-line argument string (not the allocated array), so deleting j would be wrong. However, the allocation itself should be freed before reassigning j. The question asks how to delete the pointer at the marked location, and the array form delete[] matches the original new[] allocation.