发现c/c++中对字符串的处理,没有更高级语言中那么方便,下面贴出一个代码段:
// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string subjectiveImgName ="subjectiveImg";
string jpg =".jpg";
char buffer[10];
string filename;
for(int i =0;i<3;i++)
{
sprintf(buffer,"%d",i);
string tmp = string(buffer);
filename+= subjectiveImgName;
filename+=tmp;
cout<<filename <<endl;
filename = "";
}
return 0;
}