Here is my problem. I need to keep only the filename from a filepath. For example, if the whole path is like
LPCTSTR str = "C:\\Test\\pic.bmp";
How do I retrieve just the pic.bmp into a string?
Thanks
Here is my problem. I need to keep only the filename from a filepath. For example, if the whole path is like
LPCTSTR str = "C:\\Test\\pic.bmp";
How do I retrieve just the pic.bmp into a string?
Thanks
Y3K Network http://www.y3knetwork.com
Bringing the software of the future on the net.
Could you not iterate from the end of the string, back until you reach the first '\' you come across and then iterate forward again copying the data into another string?
Yea, i did that right after posting
Thanks anyway!
Y3K Network http://www.y3knetwork.com
Bringing the software of the future on the net.
Why iterate at all? The wonderful functions of <cstring> can probably do it better and in less space :-)
Code:char *p; char buff[1024]; if ((p = strrchr(str, '\\\')) != 0) { strcpy(buff, p+1); // Now buff has "pic.bmp" }
*Cela*