#include <stdio.h>
int main (void)
{
char c = 'A';
char s[] = abcdefghijklmnopqrstuvwxyz;
int i = 999;
short int j = 17;
unsigned int u = 0xf123U;
long int l = 12312L;
long long int L = 0x1234567812345678LL;
float f = 12.978F;
double d = -12.3456;
char *cp = &c;
int *ip = &i;
int c1, c2;
printf (Integers:\n);
printf (%i %o %x %u\n, i ,i ,i, i);
printf (%x %X %#x %#X\n, i, i, i, i);
printf (%+i % i %07i %.7i\n, i, i, i, i);
printf (%i %o %x %u\n, j ,j ,j, j);
printf (%i %o %x %u\n, u ,u ,u, u);
printf (%ld %lo %lx %lu\n, l ,l ,l, l);
printf (%lli %llo %llx %llu\n, L ,L ,L, L);
printf (\nFloats and Doubles:\n);
printf (%f %e %g\n, f, f, f);
printf (%.2f %.2e\n, f, f);
printf (%.0f %.0e\n, f, f);
printf (%7.2f %7.2e\n, f ,f);
printf (%f %e %g\n, d ,d ,d);
printf (%.*f\n, 3 ,d);
printf (%*.*f\n, 8 ,2 ,d);
printf (\nCharacters:\n);
printf (%c\n, c);
printf (%3c%3c\n, c, c);
printf (%x\n, c);
printf (\nStrings:\n);
printf (%s\n, s);
printf (%.5s\n, s);
printf (%30s\n, s);
printf (%20.5s\n, s);
printf (%-20.5s\n, s);
printf (\nPointers:\n);
printf (%p %p\n\n, ip, cp);
printf (This%n is fun.%n\n, &c1, &c2);
printf (c1 = %i, c2 = %i\n, c1, c2);
return 0;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。