I have the following code:
std::string extract() {
fstream openfile("/home/name/Documents/testfile");
std::string teststring;
long location = 4;
long length = 2;
teststring.resize(length);
char* begin = *teststring.begin();
openfile.seekp(location);
openfile.read(begin, length);
return teststring;
}
This code should return a string of characters found in the file. For example, if the contents of a file
StackOverflow
this method should return
kO
This code was provided to me by a friendly user of StackOverflow. My problem is that I get a compilation error that reads: "Invalid conversion from char * to char". The problem is
char* begin = *teststring.begin();
lines. How can i fix this?
source
share