Question: When i compile this code, I get soft errors with the int and char pointers, i want to understand why and how i can correct

When i compile this code, I get soft errors with the int and char pointers, i want to understand why and how i can correct it, I try to compile the code in my gcc terminal and it errors out,
#include
#include
int main(void)
{
// Part 1
unsigned int x;
unsigned int* px= &x;
// Part 2
int* py =(int*)malloc(sizeof(int));
// Part 3
printf("Enter the unsigned int 0xaabbccdd in hexadecimal form : ");
scanf("%x",&x);
// Part 4
printf("Enter the int 0x12345678 in hexadecimal form : ");
scanf("%x",&*py);
// Part 5
unsigned char* pc;
int i;
//Part 6
printf("Value in x : %x
",x);
printf("Address in px : %p
",px);
printf("Value in *py : %x
",*py);
printf("Address in py : %p
",py);
// Part 7
pc =(unsigned int*)&x;
for(i=0;i4;i++)
{
printf("Value of pc : %p
",pc);
printf("Value of *pc : %x
",*pc);
pc++;
}
// Part 8
pc = &px;
for(i=0;i4;i++)
{
printf("Value of pc +%d : %p
",i,(pc+i));
printf("Value of *(pc+%d ): %x
",i,*(pc+i));
}
// Part 9
pc =(int*)&*py;
for(i=0;i4;i++)
{
printf("Value of pc : %p
",pc);
printf("Value of *pc : %x
",*pc);
pc++;
}
pc = &py;
for(i=0;i4;i++)
{
printf("Value of pc +%d : %p
",i,(pc+i));
printf("Value of *(pc+%d ) : %x
",i,*(pc+i));
}
// Part 10
free(py);
return 0;
}
When i compile this code, I get soft errors with

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!