C++中图片重命名实现代码分享

—-想了解C++中图片重命名实现代码分享的全部内容且更多的C语言教程关注<计算机技术网(www.ctvol.com)!!>

非常简单的小程序,满足自己的需求。

  #include <iostream>  #include <fstream>  #include<sstream>  using namespace std;     int main()  {    int i=1,j=1;   //本人程序中,i 和 j 是介于(0-9之间的数字),为了简单起见,这里给定初始值。    string fname1= "C:\Users\Administrator\Desktop\121.bmp";  //源文件    string fname2 = "C:\Users\Administrator\Desktop\";       ostringstream oss;    oss<<i<<j<<".bmp";    fname2 += oss.str(); //将int型变量和string变量相加在一起    //cout<<fname2<<endl;       fstream f;    f.open(fname1.c_str());    if(!f)    {      cout<<"图片不存在!"<<endl;    }    else    {            rename(fname1.c_str(),fname2.c_str());      cout<<"成功将重命名为"<<endl;         f.close();    }       return 0;     }

文章到此结束,需要的朋友可可以参考一下。

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/488077.html

(0)
上一篇 2020年11月12日
下一篇 2020年11月12日

精彩推荐