This code:
Copy
LPCTSTR szr = CA2T(szReplaceFile);
is equivalent to this:```
```cpp
LPCTSTR szr;
{
CA2T temp(szReplaceFile);
szr = temp.operator LPTSTR();
}
As the memory allocated by the temporary object and returned from the cast operator is destroyed when the temporary object is destroyed, using the value in szr will have undesirable results.
Instead, use this code:
CA2T szr(szReplaceFile);
The cast operator makes the CA2T object look like a LPCTSTR.