Re: split a /path/filename into components
- From: kenneth kahn <kenkahn@xxxxxxxxxxxxx>
- Date: Sat, 26 Aug 2006 12:40:02 -0400
Eric wrote:
Is there a C library function that can take a path and break it into its
component parts? I think dos has one called fnsplit but i cant seem to find
an equal in the linux world
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int ArgC,char *ArgV[]) {
char *Ptr;
char path[255],file[64];
Ptr = strrchr(ArgV[1],'/');
strcpy(path,(Ptr == NULL) ? "./" : (Ptr[0]='\0',ArgV[1]));
strcpy(file,(Ptr == NULL) ? ArgV[1] : Ptr+1);
printf("path=%s file=%s\n",path,file);
return 0;
}
.
- Follow-Ups:
- Re: split a /path/filename into components
- From: Jan Panteltje
- Re: split a /path/filename into components
- Prev by Date: Re: IDE for Linux with good code completion
- Next by Date: Re: split a /path/filename into components
- Previous by thread: Re: split a /path/filename into components
- Next by thread: Re: split a /path/filename into components
- Index(es):
Relevant Pages
|