?
Solved

Left/Right justify ?

Posted on 2001-08-11
6
Medium Priority
?
506 Views
Last Modified: 2010-04-15
printf("%5d %20s %2c %8s %10s %10s %10s\n", test1, test2, test3....);

Above printf statement will print right justify. How do I make it left justify ?
0
Comment
Question by:weiyee08
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
roaknog earned 180 total points
ID: 6375394
#include <stdio.h>
void main(){
printf("\nright\n%10c\t%5i\%20x",'z',2,13);
printf("\nleft\n%-10c\t%-5i\%-20x",'z',2,13);
}
0
 
LVL 1

Expert Comment

by:roaknog
ID: 6375396
//you did not need the \t in my answer
// to left justify you use the - flag after the %
#include <stdio.h>
void main(){
printf("\nright\n%10c%5i\%20x",'z',2,13);
printf("\nleft\n%-10c%-5i\%-20x",'z',2,13);
}
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6376312
use minus signs
printf("[%5d][%20s][%9d][%8s]", 1, "this", 14, "that");

printf("[%-5d][%-20s][%-9d][%-8s]", 1, "this", 14, "that");
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Expert Comment

by:Triskelion
ID: 6801839
Um...
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6801962
No response here, will be force accepting later today to close.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6802000
Recommendation from this applied and finalized today.
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20266763
Moondancer
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question