Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Structures and Pointers 1

Status
Not open for further replies.

ebuBekir

Technical User
Sep 6, 2001
22
0
0
DE
I have big problems with structures!

typedef struct {WORD pixel;
int i;
int j;
int iStart;
int iMax_i;
int iMin_i;
double dAngle;
double dDistance;
CString csDecision;
int n;
} MfContour2D;

MfContour2D* Funct();

MfContour2D* pTmp = 0;

The function returns a pointer on some kind of a list of structure.
pTmp =Funct();

I want to point at places immediately after that ‘list’
pTmp += pTmp->n;
But I get problems, as at that place pTmp->n is not evaluable.
(Error: Expression cannot be evaluated!)

Can you please help me?
Thanks for your help!
agurcan@hotmail.com :cool:
 
You said that the function Funct() will return a list ( address of a list) not an array of structures.

You are incrementing the pointer variable pTmp by n times, This is posible while using an array(with number elements in the array are > n).

While creating a list you may used the dynamic memory allocation functions, it will allocated memory from the heap (from the available free memory of data/code segment )memory area, so the memory allocated for the list elements will not be in queue form. so that the pTmp += pTmp->n will give problems.


so use selfreferential structure, traverse the list and reach the last element ( like linked lists).

Maniraja S
 
MfContour2D Tmp;
int addr_begin = (int)&Tmp;
int addr_end = pTmp + sizeof(Tmp) - 1; Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top