DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Just started (http://www.daniweb.com/forums/thread162093.html)

cplspls Dec 13th, 2008 9:00 am
Just started
 
I am kind of a neophite and I need your help in the following;
How do you right justify the field output in the <iostream> headerfile and how would one determine the compiler one is using/

Ancient Dragon Dec 13th, 2008 9:59 am
Re: Just started
 
The answer to the first question is easy
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    cout << right << setw(20) << "Hello\n";
}

For the second question, there is no portable way to do that. Some compilers pre-define macros that indicate the compiler and compiler's version, while other compilers don't. So the only sure-file way to do it is to declare the macros yourself for each compiler you want to support.

cplspls Dec 13th, 2008 10:16 am
Re: Just started
 
Thanx


All times are GMT -4. The time now is 3:06 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC