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 09:29:08
|
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 > |