29. Reset Fault Buffer

Back To All Submissions
Previous Submission
Next Submission
#include <iostream>
using namespace std;

int main() {
    int code;
    cin >> code;

    int *p=new int(5);
    *p=code;
     cout<<*p<<" ";
     delete p;
     p=nullptr;
     if(p==nullptr){
        cout<<"OK"<<endl;
     }
     else{
        cout<<"NOT_OK"<<endl;
     }

    return 0;
}

Solving Approach

 

 

 

 

 

Was this helpful?
Upvote
Downvote