View Single Post
Old Jul 24th, 2008, 12:08 PM   #16
francoispress
Newbie
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 francoispress is on a distinguished road
Re: How to retrieve file name without path?

The easiest way is to start from the back of the string and search for the "\\". This is easy. Once you have the pointer you can display the file name.

int len = strlen(fname);
int pos = len - 1;
char* name = NULL;

while (pos >= 0)
{

    if (fname[pos] == '\\')
    {

        pos++;
        name = fname + pos;
        printf("fname=%s\n", name);

    }

    pos--;

}
francoispress is offline   Reply With Quote