Thread: Arrays and the POINT structure

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Arrays and the POINT structure

    Ok some of you might know that I have Sams Teach Yourself C++ in 21 days. So I you know read what they had on arrays, but then (which is not a whole lot) so now I am reading Programming Windows by Petzold......I stumbled upon this......


    POINT apt[5] = { 100, 100, 200, 100, 200, 200, 100, 200, 100, 100 } ;



    it says an array of five but then it has 10 elements, so I am guessing this is because it's part of a POINT structure which is a pair of values.........am I at least on the right track? Please reply ASAP I need this to go on.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    im thinking your assumption is right?
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    WOHOOOOOOOOOO you wouldn't imagine how many times I refreshed this page............. thanks
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    5

    Unhappy

    I'm a new commer, I hope everbody will help me more. Now, i'm learning C++ programing, and i'm afraid with pointer very much, i have read Sams Teach Yourself C++ in 21 days but sometimes i don't understand too much about pointer, someone can help me?

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Best guess: You're looking at a "window/rectangle". (Check the values against the coordinates of a rectangle.)

    In short, they're x,y coordinates.

    May explain why the initialization of the "array" is mirror-image of itself.

    (Note how the last pair of values match the first.)

    I'm not a "windows" programmer, but try to find out how POINT is defined. May give you a clue.

    (I'm not breaking any new ground here, am I? )

    -Skipper

    P.S. Where, in the world, did all of the superfluous postings come in?
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    POINT and pointer are quite different. POINT is a structure defined in one of the windows header files. It contains two variables that represent an x location and a y location.

    A pointer is simply a memory address. For example, look at the following code:
    Code:
    int *pnum;//declares a pointer
    int number;//declares an int
    number=4;//sets number equal to 4
    pnum=&number;//makes pnum 'point' to number
    cout<<number //outputs 4
           <<endl<<*pnum //outputs a new line then 4 because 4 is the value stored at the address of number
           <<endl<<pnum; //outputs a new line then the memory address
    
    number=6;
    cout<<number<<endl<<*pnum;  //outputs 6 twice because pnum points to number;
    Basically, to get the value at the address, you use the * (dereference operator). To get the actual memory address, you leave out the *.

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    Code:
    typedef struct tagPOINT
    {
        LONG  x;
        LONG  y;
    } POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;
    always looking, make an offer. get me out of this place.

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    Golfinguy4,

    As I said, not a "windows" programmer. (Could you tell?) Thanks for the clarification. Good info.

    Hershlag,

    Guess that's what I was, sort of, expecting to see pop up. Thanks.

    -Skipper

    (P.S. This is Elchulo's post and I'm thanking everyone . Well, darn it, I appreciate the input!)
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  9. #9
    Registered User
    Join Date
    Aug 2002
    Posts
    5

    Wink

    wow!!! that room is interesting!!!!
    thanks a lot tutors, i've just learnt about C++ , i think that room is good for me, thanks a lots

  10. #10
    Registered User
    Join Date
    Aug 2002
    Posts
    5
    sorry i have a exercise like that, as i know with this exercise i must use about 4 times 'for condition'. but when i write i can't find the way to solve it, some one can help me:

    Write a program that reads a character string & prints out each word in a separate line. A word consist of consecutive characters delimeted by spaces or the beginning or the end of the string.
    thanks , i don't need you write for me a code but i want to know , if i don't use that way how i can do another way???
    please explain for me the way you solve

  11. #11
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Thanks guys for the help.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  12. #12
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Look up the function strtok.

Popular pages Recent additions subscribe to a feed