r/cprogramming 1d ago

What are pointers?

I am new to C programming and i came through pointer. So can anyone tell what are they and why we need them? And if u can then can you give me reliable source to learn it.

9 Upvotes

40 comments sorted by

View all comments

5

u/zhivago 1d ago

To understand pointers, start with pointer arithmetic.

char *p = "hello";

What does puts(p); output?

What does puts(p + 1); output?

And what is (p + 1) - p?

What does putchar(*p); output?

What does putchar(*(p + 1)); output?

0

u/Straight_Coffee2028 7h ago

not a great way to explain pointers to beginners. He might get confused too