int A[3];
int *ptr = A; // ptr указывает на A[0]
ptr += 2; // ptr указывает на A[2]
ptr --; // ptr указывает на A[1]
ptr = ptr+10; // ptr указывает за пределы массива A
void divide(int num, int div) {
int quot, rest, pos;
int positions[1000];
char out[1024];
printf("%d / %d = ", num, div);
for (pos = 0; pos < 1000; pos++)
positions[pos] = -1;
quot = num / div;
rest = num % div;
pos = sprintf(out, "%d", quot);
if (rest)
out[pos++] = '.';
while (positions[rest] == -1 && rest) {
positions[rest] = pos;
num = rest * 10;
quot = num / div;
rest = num % div;
out[pos++] = quot+'0';
}
out[pos] = 0;
if (rest == 0)
printf("%s\n", out);
else
printf("%.*s(%s)\n", positions[rest], out, out+positions[rest]);
}
long val = 0x12345678;
printf("long: %ld\n", val);
printf("short: %d %d\n", ((short *)(&val))[0], ((short *)(&val))[1]);
printf("char: %d %d %d %d\n", ((char *)(&val))[0], ((char *)(&val))[1], ((char *)(&val))[2], ((char *)(&val))[3]);
union {
long l;
short s[2];
char c[4];
} val;
long val.l = 0x12345678;
printf("long: %ld\n", val.l);
printf("short: %d %d\n", val.s[0], val.s[1]);
printf("char: %d %d %d %d\n", val.c[0], val.c[1], val.c[2], val.c[3]);