Wednesday, April 19, 2017
Different Format specifiers available in C except for usual one
Different Format specifiers available in C except for usual one
Guyz I assume that most of the format specifiers of C which are frequently used are known by everyone of us e.g %d for int , %f for float , %c for char , %s for string , %ld for longint ,%lf for double etc so guyz here I am to talk about some other format specifier which are not usually seen in books or not taught in normal classes. so here is the list try to use them in C program, and let me know
%i | To print integer same as %d |
%u | To print unsigned integers |
%x | To print integer value in hexadecimal format |
%o | To print integer value in octal format |
%p | Same as %x but used to print value of pointer( memory addresses) |
%hd | For short integer |
%lu | For long unsigned |
%e and %g | To printf float. |
#include<stdio.h>
int main()
{
float f= 3.43;
int i = 16;
printf( " %e " , f);
printf( " %g " , f);
printf( " %x " , i);
printf( " %o " , i);
}
on Gcc output is:
3.430000e+00
3.43
10
20
let me know your opinions about this post.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.