Page 1 of 4 123 ... LastLast
Results 1 to 15 of 47
  1. #1
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love

    Pointers/addresses

    Pointers

    I read this and I kind of understand it...

    You use ted = &var to say ted points to address of var

    You use *ted to say value pointed by ted

    You use * var to declare a pointer of the type that precedes it.


    I don't understand the arrays part...

    I use the code:[php]
    char array[] = "hello there";
    [/php]
    and it works, so why wouldn't

    [php]
    array = "hello there";
    [/php]
    not be valid? I don't understand...
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  2. #2
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Because its an array. Char only holds 1 character

  3. #3
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Koreans View Post
    Because its an array. Char only holds 1 character
    ok...

    how bout
    int numbers [20];
    int * p;
    int = p;

    why would that not be valid... int holds up to 60k integers...
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  4. #4
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Quote Originally Posted by VvITylerIvV View Post
    ok...

    how bout
    int numbers [20];
    int * p;
    int = p;

    why would that not be valid... int holds up to 60k integers...
    ints can hold a VALUE of around 65k.

    And

    [php]int = p;[/php]
    is illegal. thats like saying int is p.

  5. #5
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Koreans View Post


    ints can have a VALUE of around 65k.

    And

    [php]int = p;[/php]
    is illegal. thats like saying Int is p.

    no, int = "p"; would be saying it is p

    int = p is saying int = value of p...
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  6. #6
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Quote Originally Posted by VvITylerIvV View Post
    no, int = "p"; would be saying it is p

    int = p is saying int = value of p...
    int is a variable type

    you cant assign a value to it
    Last edited by Auxilium; 08-10-2010 at 06:07 PM.

  7. The Following User Says Thank You to Auxilium For This Useful Post:

    Hell_Demon (08-11-2010)

  8. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Koreans speaks the truth. The compiler won't allow that, ever...

  9. #8
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Here is a simple program that creates a pointer to an integer

    [php]#include <iostream>
    using namespace std;

    int main()
    {
    int apple = 5;
    int *pApple = &apple;

    cout << *pApple << '\n';
    return 0;
    }



    [/php]

    Output:
    Code:
    5
    Since pApple points to apple, when we [php]cout << *pApple;[/php] were really getting the value of apple

    REMEMBER: Initialize a pointer to something or else youll have a wild pointer and can cause unwanted behavior. Even if youre not using it right away, initialize it to 0

  10. #9
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Koreans View Post


    int is a variable type

    you cant assign a value to it
    Quote Originally Posted by Void View Post
    Koreans speaks the truth. The compiler won't allow that, ever...
    Well, I was just trying to ask why can't I assign a value from a variable to an array.

    Quote Originally Posted by Koreans View Post
    Here is a simple program that creates a pointer to an integer

    [php]#include <iostream>
    using namespace std;

    int main()
    {
    int apple = 5;
    int *pApple = &apple;

    cout << *pApple << '\n';
    return 0;
    }



    [/php]

    REMEMBER: Initialize a pointer to something or else youll have a wild pointer and can cause unwanted behavior. Even if youre not using it right away, initialize it to 0
    I know how to use pointers, it was the array part that confused me... I don't understand it.
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  11. #10
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Koreans View Post
    Here is a simple program that creates a pointer to an integer

    [php]#include <iostream>
    using namespace std;

    int main()
    {
    int apple = 5;
    int *pApple = &apple;

    cout << *pApple << '\n';
    return 0;
    }



    [/php]

    Output:
    Code:
    5
    Since pApple points to apple, when we [php]cout << *pApple;[/php] were really getting the value of apple

    REMEMBER: Initialize a pointer to something or else youll have a wild pointer and can cause unwanted behavior. Even if youre not using it right away, initialize it to 0
    Right, 'cause reading at address 0 definitely won't give you access violation errors.

  12. #11
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Then why did you ask me why cant you do [php]int = p[/php]?

    Quote Originally Posted by Void View Post
    Right, 'cause reading at address 0 definitely won't give you access violation errors.
    You re-assign it when youre going to use it
    amiright /?

  13. #12
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Koreans View Post
    Then why did you ask me why cant you do [php]int = p[/php]?



    You re-assign it when youre going to use it
    because I didn't know how to explain my question then...
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

  14. #13
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Koreans View Post
    Then why did you ask me why cant you do [php]int = p[/php]?



    You re-assign it when youre going to use it
    amiright /?
    Then just leave the default value wild and re-assign it later. Same results.. |:

    Anyways, arrays are basically pointers..

    [php]
    int array[] = {1,2,3,4,5};
    [/php]

    To access the last integer in the array, you can either use the brackets ( arrays ).
    [php]
    cout << array[4];
    [/php]

    Or you can use pointers.

    [php]
    cout << *(array+4);
    [/php]

    Remember, the first element is always 0, so if you have 5, the last one is going to be 4. Incase you didn't already know.

  15. The Following User Says Thank You to Void For This Useful Post:

    VvITylerIvV (08-10-2010)

  16. #14
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Quote Originally Posted by Void View Post
    Then just leave the default value wild and re-assign it later. Same results.. |:

    Anyways, arrays are basically pointers..

    [php]
    int array[] = {1,2,3,4,5};
    [/php]

    To access the last integer in the array, you can either use the brackets ( arrays ).
    [php]
    cout << array[4];
    [/php]

    Or you can use pointers.

    [php]
    cout << *(array+4);
    [/php]

    Remember, the first element is always 0, so if you have 5, the last one is going to be 4. Incase you didn't already know.
    I'm just restating what mah bewk said

  17. #15
    VvITylerIvV's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    The streets
    Posts
    668
    Reputation
    5
    Thanks
    61
    My Mood
    In Love
    Quote Originally Posted by Void View Post
    Then just leave the default value wild and re-assign it later. Same results.. |:

    Anyways, arrays are basically pointers..

    [php]
    int array[] = {1,2,3,4,5};
    [/php]

    To access the last integer in the array, you can either use the brackets ( arrays ).
    [php]
    cout << array[4];
    [/php]

    Or you can use pointers.

    [php]
    cout << *(array+4);
    [/php]

    Remember, the first element is always 0, so if you have 5, the last one is going to be 4. Incase you didn't already know.
    Ok, so in this case...


    [php]
    array [3]
    [/php]

    points to the address of array [3], doesn't actually hold a value?
    Favourite quotes:

    Code:
    I don't need easy, I just need possible. ~ Me 
    
    There are three birds on a fence. Two decide to fly away, how many are left? Three, just because you decide to do something doesn't mean you've done it. ~ Don't know who said this
    
    Do not go where the path may lead, go instead where there is no path and leave a trail. ~ Ralph Waldo Emerson
    Quote Originally Posted by VirtualSia View Post
    You both have a very weird and awkward view on Computer science.
    Computer science is about computing, which is programming.
    Definition of computing: The use or operation of computers.
    Turning on my computer = computing = programming
    LAWLFAIL

Page 1 of 4 123 ... LastLast

Similar Threads

  1. The Enemy Player Pointer Address
    By NOOB in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 39
    Last Post: 10-23-2010, 08:07 PM
  2. [Help]Pointer Address
    By 258456 in forum C++/C Programming
    Replies: 6
    Last Post: 09-03-2010, 12:45 AM
  3. Finding static pointer address? C++
    By scriptkiddy in forum C++/C Programming
    Replies: 0
    Last Post: 10-06-2009, 07:35 PM
  4. no fall damage addresse and pointer or value
    By 123456789987654321 in forum WarRock - International Hacks
    Replies: 2
    Last Post: 06-28-2007, 06:04 PM
  5. Kurwa Need A Weapon Pointer Work Address!
    By yogilek in forum WarRock - International Hacks
    Replies: 3
    Last Post: 06-04-2007, 11:20 AM