欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當前位置:主頁 > 軟件編程 > C語言 >

C++ 讀寫文件安全又簡潔的簡單實例

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C語言|點擊: 次

C++ 讀寫文件安全又簡潔的簡單實例

實例代碼:

#include <string> 
#include <iostream> 
#include <fstream> 
 
using namespace std; 
 
int get_file_content(string sFileName, string& sFileContent); 
 
int main(int argc, char* argv[]) 
{ 
  string sFileContent; 
  get_file_content("./test", sFileContent); 
  cout << sFileContent << endl; 
  return 0; 
}  
 
int get_file_content(string sFileName, string& sFileContent) 
{ 
  ifstream ifs (sFileName.c_str(), ifstream::in); 
 
  sFileContent.clear(); 
  char c; 
    while (ifs.get(c)){ 
    sFileContent.append(1, c); 
  } 
 
  ifs.close(); 
 
  return 0; 
} 
 
int set_file_content(string sFileName, string& sFileContent) 
{ 
  ofstream ofs(sFileName.c_str(), ofstream::binary); 
  size_t nCount = sFileContent.size(); 
  ofs.write (sFileContent.c_str(), nCount); 
  
  ofs.close(); 
 
  return nCount; 
} 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

上一篇:C++ 排序插入排序?qū)嵗斀?/a>

欄    目:C語言

下一篇:C++獲取指定目錄下的所有文件

本文標題:C++ 讀寫文件安全又簡潔的簡單實例

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/1462.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有