# Arrays and the POINT structure

Printable View

• 08-01-2002
incognito
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.
• 08-01-2002
no-one
im thinking your assumption is right?
• 08-01-2002
incognito
WOHOOOOOOOOOO you wouldn't imagine how many times I refreshed this page.............:D thanks
• 08-01-2002
koala
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?
:o :confused: :rolleyes:
• 08-01-2002
skipper
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?
• 08-01-2002
golfinguy4
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 *.
• 08-01-2002
Hershlag
Code:

```typedef struct tagPOINT {     LONG  x;     LONG  y; } POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;```
• 08-01-2002
skipper
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 :D. Well, darn it, I appreciate the input!)
• 08-01-2002
koala
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
• 08-01-2002
koala
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:( :rolleyes:
• 08-02-2002
incognito
Thanks guys for the help.
• 08-02-2002
golfinguy4
Look up the function strtok.