C pointers explained👉

Ғылым және технология

C pointers tutorial example explained
#C #pointers #tutorial
void printAge(int *pAge)
{
printf("You are %d years old
", *pAge); //dereference
}
int main()
{
// pointer = a "variable-like" reference that holds a memory address to another variable, array, etc.
// some tasks are performed more easily with pointers
// * = indirection operator (value at address)
int age = 21;
int *pAge = &age;
printAge(pAge);
//printf("address of age: %p
", &age);
//printf("value of pAge: %p
", pAge);
//printf("size of age: %d bytes
", sizeof(age));
//printf("size of pAge: %d bytes
", sizeof(pAge));
//printf("value of age: %d
", age);
//printf("value at stored address: %d
", *pAge); //dereferencing
return 0;
}

Пікірлер: 121

  • @mindlessmeat4055
    @mindlessmeat405511 ай бұрын

    Anytime I need to know something about programming, your channel is the first one I look for.

  • @HiiImChris
    @HiiImChris Жыл бұрын

    Just some advice.to truly understand this concept is a thorough way to apply it to your programs, I think it's best to take it slow. Don't feel bad, in my lecture I slowly and methodically took notes for hours on a 30 minute video to grasp the idea as a noob. It's ok to take your time, not all of us are coding gods. The only objective you should have is understanding it, and for each person that learns differently it's going to take varying time. As long as you come out with the knowledge, than your knowledge is just as effective as anybody elses.

  • @SK-ow4vw

    @SK-ow4vw

    Жыл бұрын

    I think that the conceptual problem about pointers begins much earlier than you might imagine. For example, let's take 'int age = 21" You said the integer 'age' has a value 21 AND an address. I then could easily say "well it also has a name 'age'. So now my question would be 'where is the string 'age' stored, where is the 'address' stored and where is the value stored.' Then I would ask 'how do you get to the actual integer value from the string 'age'? Surely to humans the string 'age' IS A POINTER to the value 21. So there is even confusion BEFORE one starts speaking about 'normal' pointers. As far as I understand it the compiler completely removes any reference to the string 'age'. Does it therefore replace the string 'age' in assembly code with the address where we can find the value 21? If so, the address that appears in the machine code IS A POINTER also to the value 21. Unfortunately we now don't have a name for it. So this whole issue for some of us needs to be cleared out of the way first before we can even start to talk about pointers. So in a nutshell: we need to know precisely what happens to the string 'age' in machine code.

  • @sueyourself5413

    @sueyourself5413

    Жыл бұрын

    @@SK-ow4vw No, no we don't. It's a reference of text, not a string.

  • @onlyeyeno

    @onlyeyeno

    9 ай бұрын

    @@sueyourself5413 I believe You actually strengthened "*Sk-ow4vw*"s argument, by seemingly missing his point... As I read his comment, the "issue" is not if the "variable-name" (age) is a string or some other "datatype". Rather according to Sk-ow4vw the "crux" of this is the fact that when describing (and thinking about" the "concept of a variable", it has both and address, a value (held at that address) AND a "variable-Name". And so when explaining Pointers in a way that totally neglects to even mention the "handling and destiny" of the "variable name" You risk to "loose/confuse" people who think that "one step further". At least that's how I read SK-ow4vw's comment. Best regards.

  • @katarinaclaes2975
    @katarinaclaes2975Ай бұрын

    nice explanation, your tips on what's good practice makes it way easier to understand

  • @abhishekmaurya8330
    @abhishekmaurya83302 жыл бұрын

    Awesome sir keep it up. You have nice way of explanation

  • @provokator-provocateur7603
    @provokator-provocateur76032 жыл бұрын

    Great video. Can you make video about void pointers, array pointers, struct pointers as well?

  • @spooders8943
    @spooders89432 жыл бұрын

    this was the clearest way someone has ever explained pointers to me. thanks

  • @tybargky461
    @tybargky461 Жыл бұрын

    As a CS major @ Virginia Tech, you have blessed me with a foundation that builds my confidence!

  • @tybargky461

    @tybargky461

    Жыл бұрын

    @@d0ubleyouteef You go to tech?

  • @dinnersandvich9329

    @dinnersandvich9329

    9 ай бұрын

    @@d0ubleyouteef what?

  • @juliannafotheringham7101
    @juliannafotheringham7101 Жыл бұрын

    great explanation, very clear, thank you!

  • @preethi2802
    @preethi28022 ай бұрын

    Finally got a clear insight into what all these denotations in pointers mean. Thanks a ton, bro

  • @BroCodez
    @BroCodez2 жыл бұрын

    #include void printAge(int *pAge) { printf("You are %d years old ", *pAge); //dereference } int main() { // pointer = a "variable-like" reference that holds a memory address to another variable, array, etc. // some tasks are performed more easily with pointers // * = indirection operator (value at address) int age = 21; int *pAge = &age; printAge(pAge); //printf("address of age: %p ", &age); //printf("value of pAge: %p ", &pAge); //printf("size of age: %d bytes ", sizeof(age)); //printf("size of pAge: %d bytes ", sizeof(pAge)); //printf("value of age: %d ", age); //printf("value at stored address: %d ", *pAge); //dereferencing return 0; }

  • @giaminhpham2281

    @giaminhpham2281

    2 жыл бұрын

    can you make another code that use cin, cout pleaseee

  • @accumulator4825
    @accumulator4825 Жыл бұрын

    Could you do a Scala series? That'd be so cool

  • @jamesharland3727
    @jamesharland372710 ай бұрын

    This is really clear, thank you! Got me though a mental block I was having on Codecademy

  • @seyhaseng1077
    @seyhaseng10772 жыл бұрын

    It would be awesome if u teach or solve the problems of languages

  • @altprsn6929
    @altprsn69298 ай бұрын

    Thank you!

  • @ajitghising8112
    @ajitghising81123 ай бұрын

    You cleared my mind about pointer with one view. Thanks a lot. I will be coming to check more videos from your channel. I’m learning c atm. Really appreciate man 🎉

  • @SleepyAizawa69
    @SleepyAizawa69Ай бұрын

    Hey bro thank you for your smooth well explained videos!❤

  • @barsceylan4559
    @barsceylan4559 Жыл бұрын

    Dude wtf!! You are a savior !!

  • @omarabbas6541
    @omarabbas654110 ай бұрын

    bro , you deserve more than like , comment and subscribe. You are amazing mashaAllah

  • @brahimkazzi5281
    @brahimkazzi528111 күн бұрын

    Thank you bro best course

  • @NNNedlog
    @NNNedlog2 жыл бұрын

    your vids are always easy to follow along. Thanks a lot

  • @advance6846

    @advance6846

    17 күн бұрын

    r you black gojo

  • @stephensagarinojr.4170
    @stephensagarinojr.417010 ай бұрын

    I would really be glad if you'd make a video about double pointers. Many videos are on youtube but it hard to understand it. and when I watch your videos, I can understand it easily. I am so thankful for all the tutotiral you made

  • @A1cJ121

    @A1cJ121

    4 ай бұрын

    A double pointer is essentially a pointer that holds the value of the memory address of another pointer. int x= 5; int *pX = &x; int **pPX = &pX;

  • @krateskim4169
    @krateskim41698 ай бұрын

    nice video

  • @tylersantiago3810
    @tylersantiago38106 ай бұрын

    bro, idk who you are, I don't know where you've been, idk what you do, but thank you, I love you 3000. I just watched this video and understood everything about pointers. It took my professor 3 class sessions to do so and I still didn't get it.

  • @ucheogordiunor4020
    @ucheogordiunor40204 ай бұрын

    Great video,can you make video on creating a simple shell in C

  • @redmor
    @redmor Жыл бұрын

    thanks bro

  • @vesnapezer683
    @vesnapezer68326 күн бұрын

    I love you seriously

  • @eeneemeenee6236
    @eeneemeenee6236 Жыл бұрын

    You're awesome bruh

  • @lookwithme3083
    @lookwithme30832 жыл бұрын

    I have a question how can somebody make so amazing hell videos.

  • @nocpich
    @nocpich3 ай бұрын

    thanks! it helped me a lot

  • @ahiamatagabriel5696
    @ahiamatagabriel56962 жыл бұрын

    Thank You.

  • @user-tp8gj6fu3n
    @user-tp8gj6fu3n6 ай бұрын

    love this

  • @sanjaykannan4549
    @sanjaykannan4549 Жыл бұрын

    top G

  • @justiceessiel6123
    @justiceessiel61234 ай бұрын

    I have understood golang pointers by understand C pointers

  • @issker8840
    @issker8840 Жыл бұрын

    thx!

  • @joevaghn457
    @joevaghn457Ай бұрын

    I've never really grasped why pointers are somehow really hard to understand for some people. I'm not trying to be condescending. I'm really not! It's literally a memory address. There's nothing more to think about other than type casting pointers and pointer arithmetic, imho. When using pointers, all your doing is working with the address of something that exists somewhere else in memory. Good video tho, it was really useful. I honestly find useful

  • @SteveCatalunyaSE

    @SteveCatalunyaSE

    19 күн бұрын

    As a beginner my issues with understanding have been: - Why the need to define the type of the underlying value if we are always talking about its address? - Why confusingly re-use the asterisk for different, but associated purposes.

  • @joevaghn457

    @joevaghn457

    19 күн бұрын

    @@SteveCatalunyaSE ah, So the type-of-pointer thing is so that the compiler knows how many bytes to advance the pointer ( pointer arithmetic: ++, +=, etc ). The reuse-of-asterisk is just for declaration. All I care about is if the asterisk is on value, it’s a dereference, if it’s on a declaration, then it’s a pointer. I hate dealing with multidimensional pointers beyond 3 levels. That stuff is extreme lol

  • @Nathan00at78Uuiu
    @Nathan00at78Uuiu4 ай бұрын

    love being a fellow bro.

  • @hakant.5806
    @hakant.58064 ай бұрын

    Pretty useful

  • @naveenkumar1853
    @naveenkumar18535 ай бұрын

    Excellent😊😊😊

  • @tushar8983
    @tushar8983 Жыл бұрын

    way too underrated

  • @frzy970
    @frzy9706 ай бұрын

    thanks😄

  • @pratiknvlogs
    @pratiknvlogs Жыл бұрын

    Which compiler and IDE is best to practice programming

  • @icantthinkofaname5558

    @icantthinkofaname5558

    Жыл бұрын

    i use visual studio and mingw64 for C

  • @giaminhpham2281
    @giaminhpham22812 жыл бұрын

    This video is great.

  • @izawasinsie55
    @izawasinsie552 ай бұрын

    U saved me in exams

  • @hoyorkilleader6021
    @hoyorkilleader6021 Жыл бұрын

    Mitico!

  • @aymanbou4847
    @aymanbou48474 ай бұрын

    The best

  • @Atomos_tech
    @Atomos_tech Жыл бұрын

    Thanks for the video, but there is something I am wondering about why the address is changing always when I restart the program !?

  • @heyaglitz

    @heyaglitz

    Жыл бұрын

    It's because your program won't always get assigned the same range of memory by Windows, it's normal and it's intended to be like that.

  • @Atomos_tech

    @Atomos_tech

    Жыл бұрын

    @@heyaglitz OK, thank you

  • @ironmonkey1990
    @ironmonkey1990Ай бұрын

    very nice

  • @OMNI_INFINITY
    @OMNI_INFINITY8 ай бұрын

    Would have been good to include a proper function and call. That was reason watched. Sigh…

  • @boyar3033
    @boyar30334 ай бұрын

    Thanks Biggus Chaddus

  • @entropic7768
    @entropic77683 ай бұрын

    2nd time its really clicking for me, probably going to have to relearn this like 20 times lmao

  • @14Elijah
    @14Elijah3 күн бұрын

    I prayed 😇🙏

  • @tybargky461
    @tybargky461 Жыл бұрын

    I LOVE YOU

  • @DelilBalci
    @DelilBalci4 ай бұрын

    Brooo... This channel is absolutely great!

  • @llamallama7
    @llamallama7 Жыл бұрын

    In what situations should I use pointers?

  • @RJ-or8bw

    @RJ-or8bw

    7 ай бұрын

    If you need to use a lot of memory that’s not standard size. If you have a struct that contains a lot of different data types, you would use a pointer to this huge chunk of data to get it all.

  • @fadiloumarou8280
    @fadiloumarou82802 жыл бұрын

    if we declare the pointer as int *pAge; then pAge = &age does the compiler consider *pAge as a null value?

  • @dotcomwhiz

    @dotcomwhiz

    2 жыл бұрын

    nope it will assign an arbitrary integer at that address

  • @PSIwolf39
    @PSIwolf394 ай бұрын

    Here's some code I wrote using pointers: #include #include #include #include #include #include #include void addition(int firstNumber, int secondNumber, int *pResult){ *pResult = firstNumber + secondNumber; } int main(){ int firstNumber = 20; int secondNumber = 39; int result; int* pResult = &result; addition(firstNumber,secondNumber,pResult); printf("%d+%d=%d",firstNumber,secondNumber,result); }

  • @danielndobe1257
    @danielndobe12579 ай бұрын

    awesome

  • @orangejuice7247
    @orangejuice7247 Жыл бұрын

    it entered uncharred territory im WHEEZING

  • @SoloRush-hl8jv
    @SoloRush-hl8jv11 ай бұрын

    hey ya bro

  • @stutikalan8265
    @stutikalan82655 ай бұрын

    I told my dad that I was taking a C programming course.... He offered to give me some pointers

  • @shervin9561
    @shervin95614 ай бұрын

    Thanks

  • @pintertenan8057
    @pintertenan80577 ай бұрын

    From a bro

  • @Garrison86
    @Garrison86 Жыл бұрын

    Leaving a random comment down below.

  • @danegaming9080
    @danegaming90806 ай бұрын

    nice

  • @Frozenflames-si8ch
    @Frozenflames-si8chАй бұрын

    good

  • @consolek1d
    @consolek1d4 ай бұрын

    Makes sense but I bet it’s difficult to apply

  • @sandersnolan6895
    @sandersnolan68952 жыл бұрын

    一直觉得挺难理解的,大一的C语言期末考还挂了,hh

  • @jaajmer1924
    @jaajmer19245 ай бұрын

    amen

  • @czsani1787
    @czsani178723 күн бұрын

  • @gustavo-rios
    @gustavo-rios Жыл бұрын

    This is a comment for the youtube algorithm

  • @bhoumik911
    @bhoumik9115 ай бұрын

    letsgo

  • @nickpantsios703
    @nickpantsios7032 ай бұрын

  • @knangurbanov2957
    @knangurbanov2957 Жыл бұрын

    r u 21 years old?

  • @dumcatgaming
    @dumcatgaming4 ай бұрын

    yea im still confused

  • @salih.karahan
    @salih.karahan2 жыл бұрын

    Elhamdülillah 🤲🏻🤲🏻 I found one video that isn't hindi english accent

  • @shavilagt1072

    @shavilagt1072

    Жыл бұрын

    hocam öğrendiniz mi c'yi?

  • @SHOURYAAAA

    @SHOURYAAAA

    Жыл бұрын

    Lmao. The problem is with you. I wont blame Indian people just because hindi is their language and are better at programming than the people of your country.

  • @diversiontv777

    @diversiontv777

    9 ай бұрын

    I hate hindi

  • @OMNI_INFINITY

    @OMNI_INFINITY

    8 ай бұрын

    Haha. Translation: Found a video that is trustworthy.

  • @burstfireno1617

    @burstfireno1617

    3 ай бұрын

    😅

  • @randerins
    @randerins9 ай бұрын

    Looks like heavy depression.

  • @psyferinc.3573
    @psyferinc.3573Ай бұрын

    sanks here's a comment.

  • @CombatMedic1O
    @CombatMedic1O23 күн бұрын

    This stuff is too hard, I give up.

  • @burstfireno1617
    @burstfireno16173 ай бұрын

    printf("value of pAge: %p ", pAge); Ehh how can this be value of pAge when the output is an address? Don't get it..

  • @VimalrajS-bm3vb

    @VimalrajS-bm3vb

    7 сағат бұрын

    instead of pAge you give *pAge then you get value

  • @rafo21pe
    @rafo21pe5 ай бұрын

    this video was quite difficult to understand

  • @zari_723
    @zari_723 Жыл бұрын

    comment...

  • @czsani1787
    @czsani178723 күн бұрын

    ❤❤❤❤❤❤❤❤❤❤💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕💕❤❤

  • @VintageSytr
    @VintageSytr Жыл бұрын

    comment

  • @gor3947
    @gor39476 ай бұрын

    apres du txa es

  • @szmidutm8556
    @szmidutm85566 ай бұрын

    Jesus it looks so confusing and pointless :D.

  • @lakshayphogat7831
    @lakshayphogat78316 ай бұрын

    thanks bro

Келесі