C Programming : Pointer

What is meaning of (*++ptr) in Pointer ?

Meaning of (*++ptr) : Consider the Following Example : int n = 20 , *ptr ; ptr = &n; printf(“%d”,*++ptr); Explanation : ‘++’ and ‘*’ both have Equal Precedence Associativity is from Right to Left ( Expression evaluated from R->L) Both are Unary (Operates on single operand ) So ‘ ++ ‘ is Performed First(…)

What is meaning of (++*ptr) in Pointer ?

Meaning of (++*ptr) in C Programming : Consider the Following Example : - int n = 20 , *ptr ; ptr = &n; printf(“%d”,++*ptr); Explanation : ‘++’ and ‘*’ both have Equal Precedence Associativity is from Right to Left ( Expression evaluated from R->L) Both are Unary (Operates on single operand ) So ‘ * ‘(…)

Precedence of ‘ * ‘ and ‘ & ‘ Operator in C Programming

Operator * Star(*) operator is used for two purposes - Multiplication In Pointer for De-referencing Some important points about De-Reference Operator * is unary operator when use in pointer. * is binary operator when used for multiplication. * inside pointer is called as “De-reference” Operator Or “Value at Operator“ Precedence of ‘ * ‘ and(…)

Pointer Addition: Adding integer value with Pointer

Adding integer value with Pointer int *ptr , n; ptr = &n ; ptr = ptr + 3; Live Example 1 : Increment Integer Pointer #include<stdio.h> int main(){ int *ptr=(int *)1000; ptr=ptr+3; printf(“New Value of ptr : %u”,ptr); return 0; } Output : New Value of ptr : 1006 Formula : ptr = ptr +(…)

Pointer Arithmatics : Decrementing Pointer Variable in C Programming

Decrementation of Pointer Variable Depends Upon : data type of the Pointer variable Formula : ( After decrementing ) new_address = (current address) - i * size_of(data type) Example : Data Type Older Address stored in pointer Next Address stored in pointer after incrementing (ptr-) int 1000 0998 float 1000 0996 char 1000 0999 Explanation(…)

Pointer Arithmatics : Incrementing Pointer Variable in C

Note : Incrementing Pointer is generally used in array because we have contiguous memory in array and we know the contents of next memory location. Incrementing pointer : Incrementing Pointer Variable Depends Upon - data type of the Pointer variable Formula : ( After incrementing ) new value = current address + i * size_of(data(…)

De-Referencing Void Pointers in C Programming Language

Prerequisite : De-Referencing a pointer How to de-reference a pointer ? Void Pointers are - General Purpose Stores the address of any type of variable Check this article to know more about void pointer. Why it is necessary to use Void Pointer ? Reason 1 : Re-usability of Pointer float *ptr; int num; ptr = &num(…)

Void Pointers : General Purpose Pointer in C Programming Language

What is Void Pointers in C : In C General Purpose Pointer is Called as void Pointer. It does not have any data type associated with it It can store address of any type of variable A void pointer is a C convention for a raw address. The compiler has no idea what type of(…)

De-Referencing Pointer using Asterisk(*) indirection operator in C Programming

De-Referencing Pointer in C Programming Language : Asterisk(*) indirection operator is used along with pointer variable Asterisk Operator is also called as value at operator When used with Pointer variable, it refers to variable being pointed to,this is called as De-referencing of Pointers Pointer De-referencing : Operation performed to access or manipulate data contained in(…)

Initialization of Pointer in C : Initializing Pointer

Prerequisite : Address Operator in C programming How to Initialize Pointer in C Programming ? pointer = &variable; Example : #include<stdio.h> int main() { int a = 10; int *ptr; ptr = &a; return(0); } Explanation : [arrowlist] Pointer should not be used before initialization. “ptr” is pointer variable used to store the address of(…)