Solved

Left/Right justify ?

Posted on 2001-08-11
6
493 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
roaknog earned 45 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now