29. Reset Fault Buffer

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

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

    // Write your safe delete + pointer reset logic here


     //intcode =new int();

     int* faultBuf =new int;
     *faultBuf=code;
 cout<<*faultBuf<<" ";

 delete faultBuf;
 faultBuf=nullptr;
 if(faultBuf==nullptr)
 {
    cout<<"OK";
 }

 else
 {
    cout<<"NOT_OK";
 }


    return 0;
}

Solving Approach

 

 

 

 

 

Was this helpful?
Upvote
Downvote