I was wondering if there is a way to dynamically allocate space to a char aray equal to the amount of spaces in the line from the file while use the getline method. (C++)
example
int main(){
char *theLine;
ifstream theFile;
//set theLine = new char[sizeOftheFileLine]
//is there a way do the above
theFile.getline(theLine, 500);
return 0;
}
If you use
std::getline
, you get the desired behavior.