Pointer Arithmetic (Increment & Decrement)

preview_player
Показать описание
C Programming: Pointer Arithmetic in C Programming,
Topic discussed:
1) Pre and post Increment in pointers.
2) Pre and post decrement in pointers.

Music:
Axol x Alex Skrindo - You [NCS Release]

#CProgrammingByNeso #CProgramming #Pointers #PointerArithmetic #PointersInC
Рекомендации по теме
Комментарии
Автор

Loving the way you explain each concept in words than a beginner can easily understand.

ifkelvin
Автор

You're so good at explaining this, thank you so much I finally understand this stuff

ceciliaw
Автор

Well done. It refreshed my understanding very quickly. I wonder if it might be more educational to write line 3 as "int **p = a;" as this reinforces the concept that the array variable (a) is implicitly a pointer to the first element of the array even though it is not declared as an int*. Writing out "&a[0]" is very convoluted when you could write the same thing simple as "a". Also, you might explicitly lay out the difference between incrementing an int vs incrementing an int** ... incrementing the int would always increase the value by 1, while incrementing an int* increases the value by the byte-width of the array type (int, 4 bytes).

DaveFer
Автор

I want to thank and proud of having this teacher and spreading amazing way of teaching

-madhu
Автор

it is more useful to us who are learning this programme and best explantion i ever seen an other like this in this app

Jai-sriram
Автор

Nice work! One question: what if I enable ASLR? Is a pointer operation still make sense? What will be the "next" address in that case?

MrPaulnara
Автор

Easy to understand this concept... thankyou sir😍

Aabara_ka_dabara
Автор

Thank you soo much ...ur videos help alot

Harry-qcbm
Автор

Sir is there any difference btwn pointers operations and pointer arothmetics???

twinklegarg
Автор

// Incrementing pointer ptr1 address;
ptr1++;

// Dereference and increment value (adding 1 to *ptr value)
(*ptr)++;
++(*p++);

*p++ // same as *(p++): increment pointer, and dereference unincremented address
*++p // same as *(++p): increment pointer, and dereference incremented address
++*p // same as ++(*p): dereference pointer, and increment the value it points to
(*p)++ // dereference pointer, and post-increment the value it
*p++ = *q++;

*(--p) //Pre decrement & dereference
*(p--) //Post decrement & dereference

// pointer to second character
&(a[1])

&x[1] is equivalent to x+1 and x[1] is equivalent to *(x+1)
&x[2] is equivalent to x+2 and x[2] is equivalent to *(x+2)

pattok
Автор

Just one question, should we not be subtracting multiples of 4 instead in order to change the address of the index.

naine
Автор

Can you please share these slides also for revision purpose

sanchitpratapsingh
Автор

1:39 in the post increment operation example you've mistakenly forgot to initialize pointer.

pspicephysics
Автор

Do u have a center in Chennai for net coaching

saradhaganesh
Автор

The precedence of paranthesis is greater than * then *(p++) first the pointer should be incremented and then the dereference operator should be used

yamalokesh
Автор

Given *p=&a[1]; then how p= 1000 at 0.43sec
Pls explain

aesthetic
Автор

should the address after an increment of 1, i.e, on p++, give 1001 instead?

naine
Автор

When p is 1000, and you increase it by 1, it surely goes to 1004, but how does that mechanism work?. I mean why not 1000++ ≠1001 here?. I know 1004 is "next" element, but how does it arithmetically interpret +1 as +1/+2/+4/+8 depending on datatype.

thekirigamist
Автор

Sir can you combine all slides into pdf and give link we will download it..

nnnaveenkumaryadav
Автор

how in *(p--) outputting 16 ??? first address will be assign and printing it then increment ? i test it my self !!!

shwanyoussif