Is cin a suitable file?

Like in, can I pass cinany function that takes an ifstream object?

+5
source share
2 answers

std::cin- This is not a file stream, but an input stream, or istream. You can pass it to any function that accepts istream.

+12
source

std::cinis std::istream.

There are few differences between a class istreamand its derivative ifstream. ifstreamallows you to open and close files, providing open(), close()and is_open(), and a constructor that calls open()- and what it is!

, istream& ifstream&.

+4

All Articles