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 | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
