Common C Conversion Characters

Part of the Beginning C Programming For Dummies Cheat Sheet

The printf() and scanf() functions use conversion characters as placeholders for various values. Conversion characters are used to indicate a value when the function runs in the final program.

Conversion Character What It Displays
%% The percent character (%)
%c A single character (char)
%d Integer value (short, int)
%e Floating-point value in scientific notation using a little E (float, double)
%E Floating-point value in scientific notation using a big E (float, double)
%f Floating-point value in decimal notation (float, double)
%g Substitutes %f or %e, whichever is shorter (float, double)
%G Substitutes %f or %E, whichever is shorter (float, double)
%i Integer value (short, int)
%ld Long integer value (long int)
%o Unsigned octal value, no leading zero
%p Memory location in hexadecimal (*pointer)
%s String (char *)
%u Unsigned integer (unsigned short, unsigned int, unsigned long)
%x Unsigned hexadecimal value, lower case (short, int, long)
%X Unsigned hexadecimal value, capital letters (short, int long)
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
Beginning C Programming For Dummies Cheat Sheet

Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.