Efficient way to get a string contains at most 3000 chars
Posted on 2004-04-10
I am trying to read a file into a string and crypt it, I don't want to use getline (since some of file does not have any specific character such as '\n'), read by char and crypt it is too slow, so I would like read amount of characters into a string, and then just crypt it.
I select 3000 character each time I read from file, my code like below...
CAN SOMEONE TEACH ME MORE EFFICIENT WAY TO DO THIS JOB???
THANK YOU SO MUCH....
// The code is work, but I would like to know if any efficient way to do this job... Thanks
const int AMOUNT = 3000;
string filename = "c:\\test.txt";
string str = "";
str = "";
for(int i = 0; i < AMOUNT && !ifile.eof(); i++)
ifile >> c;
str += c;