1 void CloseFile(FILE* ptrFile) 2 { 3 if (ptrFile == nullptr) 4 { 5 return; 6 } 7 CloseFile(ptrFile); 8 cout << "File Closed." << endL; 9 } 10 11 int main() 12 { 13 FILE* f = fopen("data.txt", "w"); 14 shared_ptr<FILE>ptrFile(f, CloseFile); 15 if (ptrFile == nullptr) 16 { 17 cerr << "Error Opening file." << endl; 18 } 19 else 20 { 21 cout << "File Opened." << endl; 22 } 23 return 0; 24 }