ifstream - C++ : Dynamic C-String Usage in ifstreamObject.getline(c string, char limit) -


i wondering if there way dynamically allocate space char aray equal amount of spaces in line file while use getline method. (c++)

example

int main(){         char *theline;     ifstream thefile;      //set theline = new char[sizeofthefileline]     //is there way above     thefile.getline(theline, 500);     return 0; } 

if use std::getline, desired behavior.

std::string theline; std::ifstream thefile;  // ....  std::getline(thefile, theline); 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -