fstream实现文件复制(并将文件名小写改成大写)
生活随笔
收集整理的這篇文章主要介紹了
fstream实现文件复制(并将文件名小写改成大写)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?使用C++的fstream類來實現
?
char*?filename?=?"C:\\grldr.mbr";//須復制文件路徑?????int?len?=?strlen(filename);?????while(?*(filename+len-1)!='\\'){?????????len--;?????}//獲得文件名??????char?temp[32];?????strcpy(temp,(filename+len));??????for?(int?i?=?0;?i<=strlen(temp);?i++)?????{?????????char?ch?=?temp[i];?????????if?(?ch>='a'&&ch<='z')?????????{?????????????temp[i]?-=?'a'-'A';?????????}?????}//修改大小寫???????????ofstream?outfile;//創建文件?????outfile.open(temp,ios::out|ios::binary);??????????ifstream?infile;//讀入待復制文件?????infile.open(filename,ios::in|ios::binary);?????if?(infile.is_open())?????{?????????char?ch;?????????infile.get(ch);?????????while(!infile.eof()){//eof文件結束標志?????????????outfile<<ch;?????????????infile.get(ch);?????????}?????????infile.close();?????}????????????outfile.close();?
轉載于:https://blog.51cto.com/purplexuan/1175745
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的fstream实现文件复制(并将文件名小写改成大写)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php读取子目录下文件内容,php小代码
- 下一篇: html做自我介绍模板,应聘自我介绍模板