English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I tried using printf but I keep getting errors. Please give a small example of use.

2007-01-25 10:35:52 · 2 answers · asked by Aaron 1 in Computers & Internet Programming & Design

2 answers

#include

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

And here is the output:


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

2007-01-25 10:50:00 · answer #1 · answered by CH95070 1 · 1 0

printf("%i", this_is_an_int);

2007-01-25 10:47:58 · answer #2 · answered by Andy T 7 · 0 0

fedest.com, questions and answers