Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 30th, 2008, 8:02 PM   #11
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Re: How to retrieve file name without path?

Okay, so I guess not "standards", but someone has already gone to the trouble for you to lay out how a basename function should perform. I can't come up with any better word.

My point was implementations already exist that follow this laid out procedure.
Sane is offline   Reply With Quote
Old May 1st, 2008, 10:21 AM   #12
CPU
Newbie
 
Join Date: Apr 2008
Posts: 15
Rep Power: 0 CPU is on a distinguished road
Re: How to retrieve file name without path?

thank you SANE for explaining what i try to imply
CPU is offline   Reply With Quote
Old Jul 18th, 2008, 4:55 PM   #13
CPU
Newbie
 
Join Date: Apr 2008
Posts: 15
Rep Power: 0 CPU is on a distinguished road
Re: How to retrieve file name without path?

Sane you are right there is a standart
PathStripPath:
http://msdn.microsoft.com/en-us/libr...56(VS.85).aspx
CPU is offline   Reply With Quote
Old Jul 18th, 2008, 5:23 PM   #14
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 498
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: How to retrieve file name without path?

Quote:
Originally Posted by CPU View Post
Sane you are right there is a standart
PathStripPath:
http://msdn.microsoft.com/en-us/libr...56(VS.85).aspx
That is only standard for MS-Windows operating system. Can't use it in *linx or any other os. So its not standard afterall. But, since you are writing a Windows program there is absolutely no harm in using that function -- just don't get confused between win32 api functions and standard C or C++ functions. The win32 api has hundreds of functions unique to that operating system -- not one of them are standard C/C++ functions.
__________________
I Like Ike. Vote for Dwight Eisenhower this November.
--This message brought to you by the the Procrastinators Club Of America.
Ancient Dragon is offline   Reply With Quote
Old Jul 18th, 2008, 6:05 PM   #15
CPU
Newbie
 
Join Date: Apr 2008
Posts: 15
Rep Power: 0 CPU is on a distinguished road
Wink Re: How to retrieve file name without path?

Maybe it is not for *nix etc. But it is a standart for windows and i asked for windows.but i dont want to argue with you again.you are a billion times more better than me
CPU is offline   Reply With Quote
Old Today, 12:08 PM   #16
francoispress
Newbie
 
Join Date: Jul 2008
Posts: 5
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
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem processing file into a char array csrocker101 C++ 1 May 8th, 2007 11:50 PM
File path in Mac OS X poopman Python 3 Feb 2nd, 2007 8:59 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 9:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM
Structure char field to a disk file ehab_aziz2001 C++ 0 Feb 10th, 2005 2:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC