-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer.c
More file actions
43 lines (32 loc) · 1.06 KB
/
pointer.c
File metadata and controls
43 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
//#define NULL (void *)0
int main(void) {
int x=5;
int *y;
printf("Adresse x=%p, Wert x=%d\n", &x, x);
/* Führt bei manchen Systemen zum Programmabsturz,
* ggf. auskommentieren. */
printf("Adresse *y=%p, Wert *y=%d(unsinn)\n", &y, *y);
printf("\ny=&x;\n\n");
/* y hat jetzt die Adresse von x. */
y =& x;
printf("Adresse x=%p, Wert x=%d\n", &x, x);
printf("Adresse *y=%p, Wert *y=%d\n", &y, *y);
printf("\nAdresse, auf die y zeigt, ist %p\n", y);
printf("und das ist die Adresse von x = %p\n", &x);
printf("\nACHTUNG!!!\n\n");
*y=10;
printf("*y=10\n\n");
printf("Adresse x=%p, Wert x=%d\n", &x, x);
printf("Adresse *y=%p, Wert *y=%d\n", &y, *y);
printf("\nAdresse, auf die y zeigt, ist %p\n", y);
printf("weiterhin die Adresse von x (%p)\n", &x);
int *c=NULL;
if(c==NULL){ printf("Der Zeiger besitzt keine gültige Adresse!\n");
return EXIT_FAILURE;
}
else {*c=10;}
printf("Der Wert &c%p c%p von *c ist %d\n", &c,c,*c);
return EXIT_SUCCESS;
}