55 lines
1020 B
C
55 lines
1020 B
C
|
/*
|
|||
|
tp-printf.c: Beispielprogramm HnP
|
|||
|
Kurzbeschreibung: stdlib C, printf() und Bitmanipulation
|
|||
|
C.Koch | HS-Emden-Leer
|
|||
|
19.04.2013 Initialversion
|
|||
|
07.11.2014 Erweiterung mit Datentypgröße und 32/64-Bit
|
|||
|
|
|||
|
Compile: gcc -o tp-printf tp-printf.c 64-Bit
|
|||
|
gcc -m32 -o tp-printf tp-printf.c 32-Bit
|
|||
|
Exec info: objdump -f tp-printf
|
|||
|
*/
|
|||
|
|
|||
|
#include <stdio.h>
|
|||
|
|
|||
|
int main(void)
|
|||
|
{
|
|||
|
int i = -1;
|
|||
|
char string[] = "+++ Hallo Ostfriesland +++";
|
|||
|
char *p = string;
|
|||
|
|
|||
|
printf("1: %s \n",p);
|
|||
|
printf("2: %u \n",i);
|
|||
|
printf("3: %c \n",i);
|
|||
|
printf("4: 0x%x \n\n",i);
|
|||
|
|
|||
|
printf("5: 0x%lx \n", (unsigned long) (&i));
|
|||
|
printf("6: 0x%lx \n", (unsigned long) (&main));
|
|||
|
printf("7: 0x%x \n",(unsigned int) ((unsigned long) (&i) & 0xffff));
|
|||
|
|
|||
|
printf("\n sizeof i: %i | p: %i\n", (int) sizeof(i), (int) sizeof(p));
|
|||
|
|
|||
|
return(0);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/* Beispielausgabe (32-Bit):
|
|||
|
linfan@camaro:~/.../beispieleC$ ./tp-printf
|
|||
|
1: +++ Hallo Ostfriesland +++
|
|||
|
2: 4294967295
|
|||
|
3: <EFBFBD>
|
|||
|
4: 0xffffffff
|
|||
|
|
|||
|
5: 0xffbcc808
|
|||
|
6: 0x804846d
|
|||
|
7: 0xc808
|
|||
|
|
|||
|
sizeof i: 4 | p: 4
|
|||
|
|
|||
|
|
|||
|
*/
|