When we load a file using fstream header, we use >>
and getline()
to get one complete line.
When writing it to an output file we use <<
Is there any other alternate way to write the line in the output file instead of <<
?
it is very simple. look the code below
#include <iostream>
using namespace std;
int main()
{
char a('a');
// cout
cout.put(a); // can only be used for characters
string hello;
//cin
cin.getline(hello);
//or
getline(cin,hello);
}
see, it was too easy;