Ask Your Question
3

What is the difference between defining a variable as type "&var = *ptr" and type "var = *ptr"?

asked 2023-05-24 05:09:24 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-24 05:21:01 +0000

huitzilopochtli gravatar image

When a variable is defined as type "&var = *ptr", it means that the variable is a reference to the address of the memory location pointed to by the pointer. Any changes made to the value of the variable will also affect the value of the data stored in that memory location.

On the other hand, when a variable is defined as type "var = *ptr", it means that the variable is simply assigned the value of the data stored in the memory location pointed to by the pointer. Any changes made to the value of the variable will not affect the value of the data stored in that memory location.

In summary, defining a variable as type "&var = *ptr" creates a reference to the data, while defining it as type "var = *ptr" creates a copy of the data.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-24 05:09:24 +0000

Seen: 9 times

Last updated: May 24 '23