Click to See Complete Forum and Search --> : Converting strings


Tapan
May 10th, 1999, 08:53 PM
i have a program whereby i create a dialog box of CFileDialog type.
i get the file name (with path) by the CFileDialog:GetPathName funtion.
i want to send the result to a function having char* as arguement.
but CFileDialog:GetPathName returns is of type 'class CString (void) const',
how do i convert?
fast help appreciated
Tapan

Bob Clarke
May 10th, 1999, 11:13 PM
CString cPath = dlg.GetPathName();
LPTSTR pString = cPath.GetBuffer(1);
someOtherFunc( pString );


If you modify the string pointed to by pString, you must call ReleaseBuffer() before using other CString member functions on the string (see the CString docs).