Added: 4 years ago
From: Spunky48
Views: 8,514
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (20)

Sign In or Sign Up now to post a comment!
  • im so dumb that you going to have to use fingers and swearing...i hate pointers ... fu*%en 'asterisk '

  • Great man....I understand them now!

    Thanks.

  • Treat me like a CHILD and we will NEVER get real. ahha

  • This is destined to be a classic...

  • ahahhaha

  • SSpoke: Great examples. thank you

  • When dynamically allocating memory, don't forget to delete kids! :P

  • The way this video explains people will get mixed up more then often this is how I mastered pointers in 1 day.

    int *x; <- pointer (Address holder) not pointing to anything but address holder goes up by int!).

    *x <- seems same as the first one but it has no int datatype in front! that means it holds the value its pointing too!

    &x <- address to pointer? NO this is address OF pointer it self!

    so whats x?

  • x <- this is SAME as int *x but without the int in front. You can't just get the address the pointer has stored in it by adding a int in front.. cuz int in front can only be used once! and thats to declare pointer so just x without a star in front means Address its holding that its points too.

    You can't understand pointers if you don't understand their purpose..

    Pointers only have one purpose thats to get stuff BACK as functions.. but functions get 1 stuff back pointers can get ALOT more!

  • Example when I gotta use em? Okay here it is. main(){ int a = 4; int b = 6; changeNumbers(a, b); Whats a and b on this line? they should be 100 and 200 right? WRONG they are still 4 and 6 :) why?? cuz when you pass stuff in functions and function stops working. they get DELETED! } void changeNumbers(int a, int b){ a = 100; b = 200; }
  • Here is pointer example.. main(){ int a = 4; int b = 6; changeNumbers(&a, &b); Whats a and b on this line? they are 100 and 200 see there u go you mastered pointers } void changeNumbers(int *a, int *b){ *a = 100; *b = 200; }
  • why did I use &a and &b you may by wondering.. the thing is.. I dont want the changeNumbers function to know a and b's values I want it to know their address! address IS GLOBAL when used with pointers!

    Address is another name for RAM (random access memory) thats right thats the same RAM in your computer..

    if you mess with pointers in a bad way.. you could change numbers in different programs! they could be dangerous if not used automatically like I did in my example I used automatically

  • I've already explained their use below and how to use them. :)

  • thanks for explaining it,

    nicely explained :)

  • very funny, but pointers are also initialized with values like all variables, so it's not pointing to nothing...

  • Initialization is optional, you can choose not to initialize a pointer but it's dangerous. Uninitialized pointers are called "wild pointers".

  • haha

  • I understand what pointers are now actually.

    but why use them? I dont know =/...

  • They're mainly used with functions. Since variables within a function are terminated when that function returns, you use a pointer to directly manipulate the address of that variable so that any changes made to the variable in that function are carried over when the function returns.

    Example:

    int myFunction(int *pMyPointer);

    When that function is called, you pass the address of your argument(s) instead, like so:

    myFunction(&myVariable);

    Any changes to that variable will carry over.

  • u might want to put this in ur description

  • Good call. Done. :)

  • no comment

  • LOL!

Loading...
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more