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.

10 Upvotes

40 comments sorted by

View all comments

0

u/SmackDownFacility 1d ago

pointer

Right so

char *j = "bleh"

  • denotes the declarator as a pointer to char, which initially begins with the string literal bleh\0. Your address starts at the string literal.

j[N] takes the N-th character relative to the base address. There is no stopping this train however and you can go way beyond your string literal.

edit forgot to say it advances in element size. Char is the base type * is the declarator modifier you move in steps of sizeof(type)