monkeyking
June 15th, 2009, 07:21 PM
Sorry for bothering you people, it works.
edit.
The basename that returns the filename without the path is defined in libgen.h and works out the box.
But its friend 'dirname' that return the directoryname,
I can't seem to track this one down.
Does anyone know if it exists for c/c++?
btw it should exist but I cant get it to work
man 3 basename
#include<iostream>
#include<cstring>
#include<libgen.h>
int main(){
const char *ch = "asdfasdf/asdf.cpp";
std::cout<<basename(ch) << std::endl;
std::cout<<dirname(strdup(ch)) << std::endl;
return 0;
}
edit.
The basename that returns the filename without the path is defined in libgen.h and works out the box.
But its friend 'dirname' that return the directoryname,
I can't seem to track this one down.
Does anyone know if it exists for c/c++?
btw it should exist but I cant get it to work
man 3 basename
#include<iostream>
#include<cstring>
#include<libgen.h>
int main(){
const char *ch = "asdfasdf/asdf.cpp";
std::cout<<basename(ch) << std::endl;
std::cout<<dirname(strdup(ch)) << std::endl;
return 0;
}