I am new to c programming and am working on a code that uses pointers.
#include <stdio.h>
int main(void) {
int x, y;
int *p_int; /* Pointer to an int */
x = 4;
y = 0;
p_int = &x; /* Pointer has address of x ("points to x") */
printf("x=%d, y=%d, *p_int=%d, p_int=%X\n", x, y, *p_int, p_int);
y = *p_int; /* Y now contains 4 also */
p_int = &y; /* Pointer now has address of y ("points to y") */
printf("x=%d, y=%d, *p_int=%d, p_int=%X\n", x, y, *p_int, p_int);
*p_int = *p_int * 2; /* Multiply what p points to by 2 */
printf("x=%d, y=%d, *p_int=%d, p_int=%X\n", x, y, *p_int, p_int);
return(0);
}
When I try to build it I am coming up with errors. I'm not sure where the errors are though. Can anyone help?