Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <malloc.h>
- #define DELTA 33
- int calls, seed=356;
- int sum_ds(int a){
- int d=DELTA;
- calls++;
- return a+d+seed;
- }
- int main() {
- printf("calls has the value: %d and is at address 0x%08X\n",calls,&calls);
- printf("seed has the value: %d and is at address 0x%08X\n",seed,&seed);
- int num;
- int *ptr;
- int **handle;
- printf("------------------\n");
- printf("num is at address 0x%08X and has the value: %d\n",&num,num);
- printf("ptr is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n ",&ptr,ptr,*ptr);
- printf("------------------\n");
- /*printf("handle is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n ",&handle,handle,*handle);*/
- num = 14;
- printf("num is at address 0x%08X and has the value: %d\n",&num,num);
- ptr = (int *)malloc(2 * sizeof(int));
- printf("ptr is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n",&ptr,ptr,*ptr);
- handle = &ptr;
- /*printf("handle is at address 0x%08X\n",&handle);*/
- /*printf("handle is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n ",&handle,handle,*handle);*/
- *(*handle+0) = num;
- printf("------------------\n");
- printf("This is a test to see what's *handle+0: 0x%08X\n",*handle+0);
- printf("This is a test to see what's *(*handle+0) value: %d and address 0x%08X\n",*(*handle+0),&*(*handle+0));
- printf("------------------\n");
- /*printf("handle is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n ",&handle,handle,*handle);*/
- *(*handle+1) = num+1;
- /*printf("handle is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n ",&handle,handle+1,*handle+1);*/
- printf("------------------\n");
- printf("This is a test to see what's *handle+1: 0x%08X\n",*handle+1);
- printf("This is a test to see what's *(*handle+1) value: %d and address 0x%08X\n",*(*handle+1),&*(*handle+1));
- printf("------------------\n");
- *ptr = num-2;
- printf("ptr is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n",&ptr,ptr,*ptr);
- ptr = #
- printf("ptr is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n",&ptr,ptr,*ptr);
- *ptr = sum_ds(num-2);
- printf("ptr is at address 0x%08X, pointing to 0x%08X, and has the value: %d\n",&ptr,ptr,*ptr);
- printf("The value of num must be the same as pointed by prt %d", num);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement