imageFile为left文件夹下名为1到10的图片
for (int i = 1; i < 10; i++)
{string ii;
int2str(i, ii);
string str = ii + ".jpg";
string imagepath = "D:\\FACE\\testsvm\\left\\";
string imagepath1 =imagepath+str;
char imagepath2[30];
strcpy(imagepath2, imagepath1.c_str());
const char* imageFile = imagepath2;
cout <<"imageFile " << imageFile << endl;
}
void int2str(const int &int_temp, string &string_temp)
{
stringstream stream;
stream << int_temp;
string_temp = stream.str(); //此处也可以用 stream>>string_temp
}
本文介绍了一个使用C++编程语言构造特定目录下一系列图片文件路径的方法。通过循环和字符串操作,该示例展示了如何生成从1到10编号的.jpg图片文件路径,并将这些路径打印出来。此代码适用于需要批量处理图片的应用场景。
3524

被折叠的 条评论
为什么被折叠?



