std::string headerInfo = " ";
//Verify stream is still in good condition
if(streamReader->good())
{
streamReader->ignore(fileSize, ':');
//work arounds =) v------------v
streamReader->getline(&headerInfo[0], sizeof(headerInfo), '\n');
}
else
{
//Error
}
return headerInfo;
The first parameter of getline wants a char* to store the data, so instead of creating an array with to many indexes(unless I add more lines of code to figure out how big i need to make my array), that wont be used, I just did this. I wanted someone to check my understanding of why this works.
a char* is a pointer that points to the address of the first index in an array of type char....So passing the address of the first index in my string works because a string is simply a char array correct?
Edit: StreamReader is a pointer to a fstream object.