Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n;
- int *variable = scanf("%d",&n);
- printf("Printing :%d",*variable);
- int n;
- scanf("%d",&n);
- int *variable = &n;
- printf("Printing :%d",*variable);
- int scanf(const char *format, ...);
- int *variable = scanf("%d",&n);
- *variable
- int n;
- int *variable = &(scanf("%d",&n), n);
- void foo(void)
- {
- int a;
- int *b = &a; //you assign the pointer `b` itself - no dereferencing
- *b = 5; //you dereference the pointer and asssign the the referenced object
- }
- void foo(void)
- {
- int a;
- int *b = &a; //b is pointing to the valid object -> the variable `a`
- int *c; //c is not pointing to valid object
- int *d; //d is not pointing to valid object
- c = malloc(sizeof(*c)); //now c is pointing to the valid object (if malloc has not failed of course)
- *c = 5 // correct no UB
- *d = 5; // incorrect - UB
- *b = 5; //correct no UB
- }
Add Comment
Please, Sign In to add comment