Re: [Dev-C++] ANSI C: How to split path and filename
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Fabien V. <fv...@fr...> - 2001-06-07 15:31:23
|
Sure it would be faster. LOL! = P And for the matter of the "/" (UNIX) and "\" ( DOS ) well, you could perform a first research on the "/" or the "\". If you don't get one then you know which one to use, and you could set a state variable to remember which one to find next. ----- Original Message ----- From: "Max The Hunted" <ma...@va...> To: <dev...@li...> Sent: Thursday, June 07, 2001 1:18 PM Subject: Re: [Dev-C++] ANSI C: How to split path and filename Why wouldn't you go from the end to the beginning, and try to find a '\'? When you do, everything after is a file, and before is the path. Similar, but I'd say a little bit faster. Max ----- Original Message ----- From: "Fabien VIVES" <fv...@fr...> To: <dev...@li...> Sent: Thursday, June 07, 2001 11:29 AM Subject: Re: [Dev-C++] ANSI C: How to split path and filename > What you can do is a loop, where the condition is " do I find another \ " ? > And you could do like this. > You find the first "\" > copy "c:\" in a string. > Look for another "\" > paste the sequel to the first string > I mean : "things\" to " c:\" > and you get a string with : "c:\things\" > then you look for another "\" > And you have : "alfa\" paste it to your string, and you get > "c:\things\alfa\" > Since you don't have anymore "\" the rest of the string will be a filename. > Use the strstr() function > strcp() ( if I remember the name ). > They are all in the string.h > Hope it helps. > > Fabien. > fv...@fr... > > ----- Original Message ----- > From: "Albert Vilella Bertran" <vil...@ya...> > To: "DevC MAILING List" <dev...@li...> > Sent: Thursday, June 07, 2001 10:50 AM > Subject: [Dev-C++] ANSI C: How to split path and filename > > > > Hello, > > how do I split my path and my filename? > > Example: > > > > c:\things\alfa\myfile.txt > > > > like: char *thepath ----> c:\things\alfa > > char *thefile ----> myfile.txt > > > > in ANSI C (or C), meaning the same way with DOS or UNIX > > > > There is anywhere to find this kind of things? (I couldn't find in the > help > > neither in Bob Stout's snippets) > > > > Thanks. > > > > _______________________________________________________________ > > Do You Yahoo!? > > Yahoo! Messenger: Comunicación instantánea gratis con tu gente - > > http://messenger.yahoo.es > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |