I am new to the C ++ world, I ran into a very trivial problem, that is, getting the file name without the extension.
I have a TCHAR variable containing sample.txt and you only need to extract the sample , I used the PathFindFileName function, it just returns the same value as me.
I tried looking for a solution, but still no luck ?!
EDIT: I always get an extension with three letters, I added the following code, but in the end I get something like Montage (2)««þîþ , how can I avoid junk at the end?
TCHAR* FileHandler::GetFileNameWithoutExtension(TCHAR* fileName) { int fileLength = _tcslen(fileName) - 4; TCHAR* value1 = new TCHAR; _tcsncpy(value1, fileName, fileLength); return value1; }
source share