- string getName(const char* full_name)
- {
- string file_name = full_name;
- const char* mn_first = full_name;
- const char* mn_last = full_name + strlen( full_name );
- if ( strrchr( full_name, '\\' ) != NULL )
- mn_first = strrchr( full_name, '\\' ) + 1;
- else if ( strrchr( full_name, '/' ) != NULL )
- mn_first = strrchr( full_name, '/' ) + 1;
- if ( strrchr( full_name, '.' ) != NULL )
- mn_last = strrchr( full_name, '.' );
- if ( mn_last < mn_first )
- mn_last = full_name + strlen( full_name );
- file_name.assign( mn_first, mn_last );
- return file_name;
- }
C++程序中获取不带文件路径和后缀的文件名
最新推荐文章于 2022-12-12 10:02:21 发布