question

AM-1611 avatar image
0 Votes"
AM-1611 asked Castorix31 answered

Storage of variable in any language?

int a; //Let say we declare variable. Line1
a=20; //Assigned the value to it. Line2
int p; //Pointer declared. Line3
p=&a; //Stores address of variable a
Line4*

Now, can anyone tell me.
Line 1: What is the address of a. Means how it gets stored.
Line2: What will be the change in it. How storage works?

At total I want to know. Variable is stored where? Not the value of variable. It just looks like variable is also working as reference.
And variable existence diminished after the variable value is assigned the address.
Because I have never seen anyplace where it shows that the variable is stored here, and it's value here.
But when we use that variable it uses it?



dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered

int p; //Pointer declared. Line3

This must be

 int *p;

See for example Pointers And Unsafe Code In C# - Everything You Need To Know


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.