You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
597 B
C
23 lines
597 B
C
#include <stdio.h>
|
|
#include <stdlib.h> // Start using EXIT_SUCCESS
|
|
|
|
int *int_point_plus_one(int *ptr)
|
|
{
|
|
/* Recieves a pointer to an integer and adds 1 to it */
|
|
printf("%p has a value of: %d\n", ptr, *ptr); //Second call is dereferencing the int at ptr location in mem
|
|
// deference the location and deference the value add one to the value, return the pointer
|
|
*ptr = *ptr + 1;
|
|
printf("%p now has a value of: %d\n", ptr, *ptr);
|
|
return ptr;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int a = 67;
|
|
int *p = &a;
|
|
|
|
int_point_plus_one(p);
|
|
int_point_plus_one(p);
|
|
|
|
return EXIT_SUCCESS;
|
|
} |