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/

Recommended Answers

All 2 Replies

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.

Thanx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.