A pointer is the address of a variable (or the address of an array slot, the address of a struct member etc.). For as long as the pointed-to variable is alive, you can access its value by dereferencing the pointer.
You could say that a pointer variable holds addresses ... adresses for any kind of 'object' ... including the address of an other pointer variable ... and in that case, you then have a 'pointer to a pointer'.
One very common use of pointers is when you allocate dynamic memory ... The pointer then holds the address to the first byte in that newly allocated memory.
it takes value of a vairable or only takes adress of vairable ??
pointer variable takes address of another variable which must be same as pointer type.you can't point float variable using pointer to int declaration.you must have pointer to float in this case.look below :
ptr=&y; //Incorrect . Because ptr is pointer to int and it can't be used to point float.
ptr=&x //Correct. Because Both type are same.the statement will assign the address of x to pointer ptr
print *ptr //*ptr is de referencing(i.e. get the value at address)
*ptr=20 //set the value at address .Now x becomes 20
here is how you delcare a pointer
let 'a' be a variable
The statement below takes the adderess of the variable a
where as the syntax given below takes the value of the variable
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...