C language pointer: I don't know why it's an error

Asked 1 years ago, Updated 1 years ago, 217 views

#include <stdio.h>


int main(void)
{

    int i = 0;

    int* pt1;
    //pt1=ar1=&ar1[0]
    //pt1 is the order of address storage, and you go to 77755 and read the value
    //*The value at pt177755 
    unsigned int valA=0;
    pt1 = valA;
    valA = 30;

    printf("Index 0 Addr: %u \r\n", &valA);

    printf ("Please enter a value");
    scanf_s("%u", &valA);

    printf("input:%u \r\n", valA);

    printf("*PT1:%u \r\n",*pt1);

    return 0;

}

c

2022-10-29 09:03

1 Answers

I think the address of valA should be assigned to pt1 instead of valA.


2022-10-29 09:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.