C
cpisz
I want to do some find and erase operations that i find in the string
class, upon the entire text contents of a file.
I made a function that will take a string (designed to hold the entire
file contents)
my problem now is how can i grab all the file contents in one swoop and
put it in a string for editing?
I hate to go through the file and copy line by line:
string s = file.getline()
while(!file.eof)
{
s += file.getline();
}
That seems aweful inefficient...
isnt there some way to initialize the string with the contents of the
file?
like:
string s(file.some data buffer)?
If I copy the contents from a file to a string and then later from a
string to a stringstream and finally from a stringstream to individual
variables I am essentially copying the file 4 times, that could stink
for large files...
class, upon the entire text contents of a file.
I made a function that will take a string (designed to hold the entire
file contents)
my problem now is how can i grab all the file contents in one swoop and
put it in a string for editing?
I hate to go through the file and copy line by line:
string s = file.getline()
while(!file.eof)
{
s += file.getline();
}
That seems aweful inefficient...
isnt there some way to initialize the string with the contents of the
file?
like:
string s(file.some data buffer)?
If I copy the contents from a file to a string and then later from a
string to a stringstream and finally from a stringstream to individual
variables I am essentially copying the file 4 times, that could stink
for large files...