Search
 
SCRIPT & CODE EXAMPLE
 

C

printf format specifiers

#include <stdio.h>

int main(){
   printf ("Characters: %c %c 
", 'a', 65);
   printf ("Decimals: %d %ld
", 1977, 650000L);
   printf ("Preceding with blanks: %10d 
", 1977);
   printf ("Preceding with zeros: %010d 
", 1977);
   printf ("Some different radices: %d %x %o %#x %#o 
", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E 
", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d 
", 5, 10);
   printf ("%s 
", "A string");
   return 0;
}

output: 
  Characters: a A
  Decimals: 1977 650000
  Preceding with blanks:       1977
  Preceding with zeros: 0000001977
  Some different radices: 100 64 144 0x64 0144
  floats: 3.14 +3e+000 3.141600E+000
  Width trick:    10
  A string
Comment

printf type format

%d--> for int

%u--> for unsigned int

%ld--> for long int or long

%lu--> for unsigned long int or long unsigned int or unsigned long

%lld--> for long long int or long long

%llu--> for unsigned long long int or unsigned long long
Comment

printf format specifiers

d decimal
c character
s string
f float
e scientific notation
x hexadecimal


 new line
	 horizontal tab
 backslash
 backspace
' single quote
" double quote
Comment

format using printf

%[flags][width][.precision]conversion-character
Comment

PREVIOUS NEXT
Code Example
C :: how to turn off zsh 
C :: copy string c 
C :: how to create calculator with switch in c 
C :: random float number in C 
C :: get last char string c 
C :: redirect to url page asp.net mvc 
C :: union in c 
C :: sequelize count multiple associations 
C :: mongodb update 
C :: c string 
C :: Access denied creating xampp-control.ini 
C :: c memset 
C :: Convert mpg / mp4 to gif with ffmpeg 
C :: C Passing Pointers to Functions 
C :: c program to find the frequency of all characters in a string 
C :: C program to check whether character is lowercase or not using ASCII values 
C :: c round float 
C :: How to pass a struct value to a pthread in c? 
C :: quick sort c 
C :: delay in c programming for windows 
C :: c include delay 
C :: c linked list 
C :: lxc Failed to load config for 
C :: how to print % in c 
C :: c char to int 
C :: oracle trunc 
C :: Example of read and write project in c 
C :: ansi c read write bmp 
C :: c get int inpot 
C :: how can i learn c game development 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =