C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 30th, 2004, 06:49 AM
perkinst perkinst is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 perkinst User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question COUT text alignment help

Hi, I'm fairly new to C++ been using M$ Visual C++ and it seems to be going ok. I need to develop a program which generates a triangle with a bunch of characters (user inputs what character to use) and also how many rows the triangle will be.

So far I've only managed to get it to be left-aligned and I cannot seem to enable it to be right aligned. The source code is below, please tell me what I am doing wrong.

#include "stdafx.h"

#include <iostream>
#include <iomanip>

using namespace std;

void main()
{
char compchar= 'Q';
int a = 0.0;


cout << " Please enter the component character ";
cin >> compchar;

cout << " Please enter the number of rows ";
cin >> a;


for(int i=0; i<=a;i++)
{
for(int ie=1; ie<=1*i; ie++)
cout << compchar ;
getchar();
cout << endl;


}

}

Any help in getting this triangle to be aligned right would be great, all I'd need to do is link it to a CIN (L for left R for right) type of thing.

Thanks,

Sparky

Reply With Quote
  #2  
Old January 2nd, 2005, 01:51 AM
popeye137 popeye137 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Queen City of the South--> Cebu Philippines
Posts: 11 popeye137 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 22 sec
Reputation Power: 0
COUT text alignment help

try gotoxy(x1,y1)

where x1 and y1 are the x, y coordinate of the monitor...



Reply With Quote
  #3  
Old January 2nd, 2005, 04:41 AM
perkinst perkinst is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 perkinst User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by popeye137
try gotoxy(x1,y1)

where x1 and y1 are the x, y coordinate of the monitor...



Nope not valid ANSI standards, dont compile with M$ visual C++ anyhow. I've been trying
cout << resetiosflags(ios::right);

but it dont seem to work.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > COUT text alignment help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT