i was told that to redirect from standard input to file i need to do the following:
static std::ifstream inF("inpur.txt");
std::cin.rdbuf(inF.rdbuf());
and every call to std::cin will be redirected to input.txt.
but my question is: do i need to open inF? and if i do, where do i need to do this?
That’s the beauty. You already did so while declaring the object and passing the string to the explicit constructor of ifstream.
The file is opened in TEXT mode.
Refer this