Tech Support Guy banner
  • Please post in our Community Feedback thread for help with the new forum software! If you are having trouble logging in, please Contact Us for assistance.
Status
Not open for further replies.
1 - 3 of 3 Posts

·
Registered
Joined
·
307 Posts
Ok, what C++ thinks you are doing is it thinks that you are entering a Octagonal value of 0457 (or 303 in oct). So, what you do is change the base of cout. Look at this code example:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
	int y = 457;
	int x = 0457;

	cout << setbase(10) << y << endl;
	cout << setbase(8) << x << endl;

	return;
}
What setbadse(int) does is it changes the type of integer output that cout displays. There are three integers that can be entered into the setbase() function: 8=Octagonal, 10=Decimal, and 16=Hexadecimal. By changing the base, you change the type of output.
 
1 - 3 of 3 Posts
Status
Not open for further replies.
Top