GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Mar-2009, 01:12
tpetsovi tpetsovi is offline
New Member
 
Join Date: Feb 2009
Posts: 7
tpetsovi has a little shameless behaviour in the past

Issue with left justification


My left justification isn't how I want it..any thoughts? After 9 the structure is off by one.

CPP / C++ / C Code:
#include <iostream>
#include <iomanip>
using namespace std;

void main ()
{
	int a, d, Days;
	
	cout << " Day       Amount \n";
	cout << "-----     --------\n";
	cout << "                  \n";


	for (a = 1, d = 1, Days = 1; Days <=30; d++, a+=a, Days++)
	{
		cout << "  " << setiosflags(ios::left) << d << "           ";
		cout << setiosflags(ios::left) << a << endl;
	}
	
}

Code:
Day Amount ----- -------- 1 1 2 2 3 4 4 8 5 16 6 32 7 64 8 128 9 256 10 512 11 1024 12 2048 13 4096 14 8192 15 16384 16 32768 17 65536 18 131072 19 262144 20 524288 21 1048576 22 2097152 23 4194304 24 8388608 25 16777216 26 33554432 27 67108864 28 134217728 29 268435456 30 536870912 Press any key to continue . . .
Last edited by admin : 04-Mar-2009 at 02:00. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #2  
Old 04-Mar-2009, 03:36
L7Sqr L7Sqr is offline
Member
 
Join Date: Jul 2005
Location: constant limbo
Posts: 234
L7Sqr is a jewel in the roughL7Sqr is a jewel in the rough

Re: Issue with left justification


look at width for streams. For example:
CPP / C++ / C Code:
cout.width(10);
cout << left << d << endl;
__________________
My personal site: Utilities for text processing, debugging, testing and plotting
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Link List In C Peter_APIIT C Programming Language 33 12-Jun-2008 14:33
Disabling left click? tvdoc Apache Web Server Forum 0 19-Jul-2007 15:06
triangle (polygon), drawing, sizing, and rotation programme using linked lists... promsan C Programming Language 12 14-May-2007 15:03
need help with a console menu system BullBuchanan C++ Forum 6 20-Aug-2006 15:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:25.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.