Hi all,

I need to read the whole content of a file in a string object.
Up to now I don't manage to do that quickly since I read the file
character by character.

here is the code I use (i want to open a PDF file):

   bool LoadPDF2String(const char * nom_fichier, std::string & contenu)
   {
       unsigned long size=GetFileLength(nom_fichier);   // function that
returns the number of char of the file
       contenu.resize(size+1,'0');

       std::ifstream fin(nom_fichier,std::ios::binary); // open in
binary mode
       if(fin)
       {
           char ch;
           unsigned long str_i = 0;
           while(fin.get(ch))
               contenu[str_i++] = ch;

           contenu[str_i] = 0;
           return true;
       }
       else
           return false;
   }


thanks a lot for your help
rapha�l


To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.


Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=795844627


Yahoo! Groups Links

Reply via email to