0

I just want to read a txt file and receive a string file like that

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

How I implement LoadFile function

user1369825
  • 596
  • 5
  • 8
  • possible duplicate of [Read whole ASCII file into C++ std::string](http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring) – Jerry Coffin May 11 '12 at 02:11

1 Answers1

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;
}

this is an example of how to read a file in it's entirety to a string buffer. It should give you a good idea on how to proceed.

James Custer
  • 827
  • 5
  • 11
johnathan
  • 2,259
  • 12
  • 20