RE: [Dev-C++] ANSI C: How to split path and filename
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2001-06-07 20:48:13
|
The previous code that I sent is for converting a dos/windows path to unix path. I hadn't read carefully what you have written. If you want to split the directory path from the filename in a dos/windows environment use this: #include <string.h> ... char s[]=3D"path\\filename"; char filename[255]; char path[1024]; size_t i; char *p=3Dstrrchr(s, "\\"); strcpy(filename, p); for(i=3D0; i<p-s; i++) path[i]=3Ds[i]; path[i]=3D'\0'; This can be done better but it is a quick (and error-prone) example. Ioannis * Ioannis Vranos * Programming pages: http://members.nbci.com/noicys * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Albert Vilella Bertran Sent: Thursday, June 07, 2001 10:51 AM To: DevC MAILING List 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=F3n instant=E1nea gratis con tu gente - http://messenger.yahoo.es _______________________________________________ Dev-cpp-users mailing list Dev...@li... http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |