I'd like to know if there is any way to open a file in C++ using the ifstream class,to read a file with the least "wordy" way (by wordy i mean a lot/redundant commands).I've seen examples where one opens a file for reading,and uses the following concept:
//commands
ifstream fin("data.txt");
char ch;
while(fin){
fin >> ch;
cout << ch;
}
Something similar happens while using the getline()
function,it would be useful if there was a function where the return value is what was read from istream(stdin or file).
I would appreciate to see some examples with using both C and C++
Thanks for your time!