2012-05-11 3 views
0

난 그냥 내가이 그것을 전체가의에서 파일을 읽는 방법의 예입니다문자열에 txt 파일을 읽는 방법?

+0

[전체 ASCII 파일을 C++ std :: string으로 읽을 수 있음] (http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring) –

답변

0
#include <fstream> 
#include <string> 
int main() 
{ 
    std::string buff; 
    std::fstream fs("filename",std::ios::in | std::ios::ate) 
    if(fs.is_open()) 
    { 
     fstream::pos_type size = fs.tellg(); 
     fs.seekg(0); 
     buff.resize(size); 
     fs.read(&buff[0],size); 
    } 
    std::cout << buff << endl; 
} 

LoadFile과 기능을 구현하는 방법이

Blob rgbBlob; 
    string strIccRGBFile = "./icc/RGB.icc"; 
    string strIccRGBContent = LoadFile(strIccRGBFile); 
    rgbBlob.update(strIccRGBContent.c_str(), strIccRGBContent.length()); 
    image.profile("ICM", rgbBlob); 

같은 문자열 파일을 TXT 파일을 읽고 수신 할 캐릭터 라인 버퍼 진행 방법에 대한 좋은 아이디어를 줄 것입니다.

+0

도움 주셔서 감사합니다 . : D – user1369825

+0

귀하의 환영 :) – johnathon

관련 문제