fstream实现文件复制(并将文件名小写改成大写)
生活随笔
收集整理的這篇文章主要介紹了
fstream实现文件复制(并将文件名小写改成大写)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?使用C++的fstream類來實(shí)現(xiàn)
?
char*?filename?=?"C:\\grldr.mbr";//須復(fù)制文件路徑?????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;//創(chuàng)建文件?????outfile.open(temp,ios::out|ios::binary);??????????ifstream?infile;//讀入待復(fù)制文件?????infile.open(filename,ios::in|ios::binary);?????if?(infile.is_open())?????{?????????char?ch;?????????infile.get(ch);?????????while(!infile.eof()){//eof文件結(jié)束標(biāo)志?????????????outfile<<ch;?????????????infile.get(ch);?????????}?????????infile.close();?????}????????????outfile.close();?
轉(zhuǎn)載于:https://blog.51cto.com/purplexuan/1175745
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的fstream实现文件复制(并将文件名小写改成大写)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php读取子目录下文件内容,php小代码
- 下一篇: html做自我介绍模板,应聘自我介绍模板