Question: My code have some error but i don't know how to fix, please help! #include #include int main(void) { int x; int *xptr; char astring[30];
My code have some error but i don't know how to fix, please help!
#include
int main(void) { int x; int *xptr; char astring[30];
puts("Please enter a number "); scanf("%d",x); printf("The number using x is %d ",x);
puts("Please enter a number "); scanf("%d",&x); printf("The number using &x is %d ",x);
puts("Please enter a number "); scanf("%d",xptr); printf("The value of xptr is %X and it holds the value %d ",xptr,*xptr);
xptr = &x; puts("Enter a new value for x"); scanf("%d",xptr);
printf ("The value of xptr is %X and x using this xptr is %d ",xptr,x); printf ("The address of x is %X ",&x);
printf("xptr is %X, *xptr is %d and &xptr is %X ",xptr,*xptr,&xptr);
puts("Ensure you understand what would happen if *xptr were used in scanf");
printf ("the char array astring is located at %X ",astring); printf ("the first character is currently %c ",astring[0]);
puts("Please enter some text"); scanf("%s",&astring);
return EXIT_SUCCESS; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
