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 132 views
132 views asked Apr 6, 2018 by avibootz
1 answer 181 views
1 answer 211 views
1 answer 314 views
1 answer 166 views
1 answer 91 views
...