how copy the content of the "fstream::rdbuf()" to a string?

W

wukexin

Hi, hot heart men:
I have a program in file input and output. I need copy the whole source file's content to a string only once, I don't know what? Help me? thank you.



wukexin
(e-mail address removed)
 
P

Phlip

wukexin said:
I have a program in file input and output. I need copy the whole
source file's content to a string only once, I don't know what? Help me?
thank you.

Read my thread "fileToString" (use http://groups.google.com and search for
my street name & fileToString).

I went with this:

std::string fileToString(std::string const& name) {
std::ifstream in(name.c_str());
std::eek:stringstream out;
out << in.rdbuf();
return out.str();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top