0% found this document useful (0 votes)
2 views6 pages

Pointer Syntax

The document discusses various pointer concepts in C that often confuse students in MCQs and interviews, such as the difference between 'p++' and '(*p)++', pointer arithmetic, and the distinction between NULL and wild pointers. It also covers the behavior of function names as pointers, the differences between arrays and pointers, and the implications of using void pointers. Additionally, it highlights common pitfalls and tricky topics related to pointers that are frequently tested in exams.

Uploaded by

treecraftlegends
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Pointer Syntax

The document discusses various pointer concepts in C that often confuse students in MCQs and interviews, such as the difference between 'p++' and '(*p)++', pointer arithmetic, and the distinction between NULL and wild pointers. It also covers the behavior of function names as pointers, the differences between arrays and pointers, and the implications of using void pointers. Additionally, it highlights common pitfalls and tricky topics related to pointers that are frequently tested in exams.

Uploaded by

treecraftlegends
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Pointers ke kuch aise concepts hain jo MCQ aur interviews me kaafi confuse kar dete hain:

1. *p++ vs (*p)++

int x = 5;
int *p = &x;

*p++;

Iska matlab:

*(p++);

Pointer aage badhega, value nahi.

Lekin:

(*p)++;

Value increment hogi ( x = 6 ).

2. p + 1 Ek Byte Nahi Badhata

int *p;

Agar int 4 bytes ka hai:

p + 1

address me 4 bytes add karega.


3. NULL aur Wild Pointer Alag Hain

int *p = NULL;

NULL pointer.

int *p;

Wild pointer (garbage address).

4. sizeof(p) vs sizeof(*p)

int *p;

64-bit system par:

sizeof(p) // 8
sizeof(*p) // 4

5. Double Pointer

int x = 10;
int *p = &x;
int **q = &p;

**q

Output:

10
6. &*p == p

&*p

Same as:

Jab tak p valid pointer ho.

7. *&x == x

*&x

Same as:

8. Pointer Comparison

int a[5];

&a[2] > &a[1]

✅ True
Array ke andar pointers compare kar sakte hain.

9. int *p, q;
Bahut students galti karte hain.

int *p, q;

Yahan:

p = pointer
q = normal int

Dono pointer nahi hain.

10. void * Universal Pointer

int x = 5;
void *p = &x;

Valid.

Lekin:

printf("%d", *p);

❌ Error
Pehle typecast karna padega.

11. Function Name Bhi Pointer Jaisa Behave Karta Hai

void fun(){}

fun == &fun

✅ True
12. Array aur Pointer Same Nahi Hote

int a[5];
int *p = a;

Ye valid hai, lekin:

sizeof(a) != sizeof(p)

Array aur pointer alag cheezein hain.

13. Famous MCQ

int a[] = {10,20,30};


int *p = a;

printf("%d", *p++);

Output:

10

Kyuki:

*(p++)

Pehle 10 print, phir pointer aage.

14. Triple Pointer Bhi Hota Hai

int ***p;
Exam me pooch lete hain:

***p

Final integer value ko access karega.

15. Dangerous MCQ

int *p = NULL;
printf("%d", *p);

❌ Runtime crash / undefined behavior.

📌 Computer Anudeshak level par sabse zyada pooche jaane wale tricky topics:
*p++ , (*p)++ , ++*p
Array vs Pointer
sizeof(pointer) vs sizeof(*pointer)
NULL, Wild, Dangling Pointer
Double Pointer ( **p )
a[i] aur i[a] equivalence.

You might also like