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 May 6th, 2005, 03:11 AM
blitz00 blitz00 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 6 blitz00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 54 sec
Reputation Power: 0
Question with aligning

for example my output is this:

Tedd, Andrew D 50.00 F
Jason, May D 54.90 C
Love, Angel D 45.00 F

But i want it to be all aligned up in a dtraight column starting from "D".
So the columd with D would but straight aliggned.

How would i do that. I tries using setw but it won't solve my problem

Reply With Quote
  #2  
Old May 6th, 2005, 04:25 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Use setw() function.

Reply With Quote
  #3  
Old May 6th, 2005, 04:28 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Oops,sorry I did not read that you mentioned about setw().
in that case, there is a function that lets you write text from specific point.
I can't remember that function name.
Try, gotoxy()

Reply With Quote
  #4  
Old May 6th, 2005, 10:40 AM
ShadowCoder ShadowCoder is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Ottawa
Posts: 20 ShadowCoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 54 m 12 sec
Reputation Power: 0
Depending on how you're storing your data you could just use the printf flags

Code:
struct Whatever
{
 char name[20];
 double num;
}myStruct;

int main(int argc, char* argv[])
{  
 strcpy(myStruct.name, "John, Doe");
 myStruct.num = 12.34;

 printf("\n%15s%10.2f", myStruct.name, myStruct.num);

 getchar();
 return 0;
}

Reply With Quote
  #5  
Old May 7th, 2005, 04:45 AM
B-Con's Avatar
B-Con B-Con is offline
:bcon: moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Location: int main()
Posts: 351 B-Con User rank is Private First Class (20 - 50 Reputation Level)B-Con User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 23 h 8 m 6 sec
Reputation Power: 4
you could also use the tab character to align everything by tabs: printf("X \t Y")
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips.



Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Question with aligning


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 6 hosted by Hostway
Stay green...Green IT