29. Reset Fault Buffer

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

int main() {
    int code;
    cin >> code;
    int* fault = new int(code);
    cout << *fault << " ";

    delete fault;
    fault = nullptr;
    cout << (fault == nullptr?"OK":"NOT_OK")<<endl;

    // Write your safe delete + pointer reset logic here

    return 0;
}

Solving Approach

 

 

 

 

 

Was this helpful?
Upvote
Downvote