9) Enter the code
#include <stdio.h>
int main(int argc, char *argv[])
{
int a;
int *b;
b = &a; // b contains the address of a
// Display the value of b and the dereferenced value
printf("b = %d, *b = %d\n", b, *b);
// Assign a value to a
a = 3245;
// Display the value of b and the dereferenced value
printf("b = %d, *b = %d\n", b, *b);
return 0;
}
• Make the following two-line addition to the end of the code
Assign the value 12345 to the dereferenced pointer b. In other words, assign the value 12345 to *b
Display the value of a.
Write a short reflective account explaining the functionality of your modifications.
#include <stdio.h>
int main(int argc, char *argv[])
{
int a = 12345;
int *b;
b = &a; // b contains the address of a
// Display the value of b and the dereferenced value
printf("b = %d, *b = %d\n", b, *b);
// Assign a value to a
a = 3245;
// Display the value of b and the dereferenced value
printf("b = %d, *b = %d\n", b, *b);
return 0;
}
Comments
Leave a comment