cpp / c++ get pointer value or depointerize pointer

前端 未结 1 1488
渐次进展
渐次进展 2021-02-03 17:32

I was wondering if it\'s possible to make a pointer not a pointer..

The problem is I have a function that accepts a pointer for an paramater for me to easily get a value

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 18:01

    To get the value of a pointer, just de-reference the pointer.

    int *ptr;
    int value;
    *ptr = 9;
    
    value = *ptr;
    

    value is now 9.

    I suggest you read more about pointers, this is their base functionality.

    0 讨论(0)
提交回复
热议问题