#include <string>
using namespace std;
/*
* assistant function,
* return a string, get tow string&,
* use to change a filename's extern name;
* author: lonelyforest
* Date: 2006.03.15
*/
string change_file_ext(const string& filename, const string& new_ext)
{
int dot_pos = 0;
string temp = filename;
for( int i = 0; i < temp.length(); ++i)
{
if ( temp[i] == '.' )
{
dot_pos = i;
}
}
temp.erase(dot_pos);
temp += new_ext;
return temp;
}
不是很好, 希望多多指教。
using namespace std;
/*
* assistant function,
* return a string, get tow string&,
* use to change a filename's extern name;
* author: lonelyforest
* Date: 2006.03.15
*/
string change_file_ext(const string& filename, const string& new_ext)
{
int dot_pos = 0;
string temp = filename;
for( int i = 0; i < temp.length(); ++i)
{
if ( temp[i] == '.' )
{
dot_pos = i;
}
}
temp.erase(dot_pos);
temp += new_ext;
return temp;
}
不是很好, 希望多多指教。