Basename函数
参考资料
http://monkeymusic.blog.163.com/blog/static/4797639200912533652666/
解释
basename - strip directory and suffix from filenames
去除给出字符串的前缀例子
Shell命令:basename a/b/c/d/test/a.ppt
输出:a.ppt
可以在后面添加一个参数,通过这个参数来去除后缀
Shell命令:basename a/b/c/d/test/a.ppt .ppt
输出:a
#include <libgen.h>
#include <stdio.h>
void main() {
char *test = "/etc/test/acb/test.ueventd";
char *t = basename(test);
printf("%s ",t);
}
输出:test.ueventd