How to create cout custom output in c++

2 Answers

0 votes
#include <iostream>
#include <iomanip> 

using namespace std;

ostream &rightarrow(ostream &stream)
{
	stream << " --> ";

	return stream;
}

int main()
{
	cout << "PI" << rightarrow << 3.14 << endl;

	return 0;
}


/*
run:

PI --> 3.14

*/

 



answered Apr 6, 2018 by avibootz
0 votes
#include <iostream>
#include <iomanip> 

using namespace std;

ostream &pl(ostream &stream)
{
	stream << "Programming Language: ";

	return stream;
}

int main()
{
	cout << pl << "C++" << endl;

	return 0;
}


/*
run:

Programming Language: C++

*/

 



answered Apr 6, 2018 by avibootz

Related questions

1 answer 142 views
142 views asked Apr 6, 2018 by avibootz
1 answer 199 views
1 answer 226 views
1 answer 330 views
1 answer 176 views
1 answer 103 views
...