Saturday, 20 January 2018

Printing of Strings | string handling functions in c programming | cs tring format


Printing of Strings

Printing of Strings
 The format specification for outting strings is of the form %w.ps  where w specifies width for display and p instructs that only the first p characters of string are to be displayed.The display is right
-justified.   The following examples show the effect of a variety of specifications in printing a string
"NEW DELHI  110001", containing 16
(including  blanks). 

Specification & Output:

 1)   %s

N E W D E L H I 1 1 0 0 0 1






2) %20s
L
N E W D E H I 1 1 0 0 0 1


3) %20.10s

N E W D E L H I



4) %.5S

N E W D



5) %-20.10s

N E W D E L H I



6) %5s

N E W D E L H I 1 0 0 0 1

Related Posts:

  • Difference Between The Macros And Functions Difference Between The Macros And Functions Macros are like functions but there is difference between those two . 1. In macro call the processor replaces the macro template with its macro expansion. Where as in functi… Read More
  • Closing A File & File Functions Closing A File & File Functions When we have finished all operations the file must be closed . This ensures that all outstanding information associated with the file is flushed out from the buffers and all links to… Read More
  • Defining And Opening A File Defining And Opening A File  If we want to store data in a file in the secondary memory, we must specify certain things about the file , to the operating system. They include:  1.File name.  2.Data Structu… Read More
  • Random Access Files Random Access Files Random access to files are required when we want to access only particular part of a file instead of reading and writing data sequentially.This can be achieved by using the functions like : fseek,fte… Read More
  • Command Line arguments Command Line arguments Definition: It is a parameter supplied to a program when the program is invoked.These are the arguments passed to the main at command prompt. Explanation: main() function in 'c' takes two argumen… Read More

0 comments:

Post a Comment