| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
COUT text alignment help
try gotoxy(x1,y1)
where x1 and y1 are the x, y coordinate of the monitor... ![]() |
|
#3
|
|||
|
|||
|
Quote:
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > COUT text alignment help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|