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!

Accessing the value of a struct

Status
Not open for further replies.

SteveBrett

Programmer
Apr 24, 2000
107
MT
Hi

I have a COM component that passes some udts around.

The function header is thus:

void App::passUdt(struct udtSR *pudtSR)

pudtSR has a member struct called udtValue1 of type udtLONG that has the definition:

struct udtLONG
{
long lngValue;
enum enumVarStatus enmStatus;
};

what i want to do is set a LONG to the value stored in the lngValue part of udtLONG.

however if I add

long lVal = pudtSR.udtValue1.lngValue;

I get the following error:

error C2228: left of '.udtValue1' must have class/struct/union type

Can anyone point me in the right direction ?

Many thanks

Steve
 
Since pudtSR is a pointer, you need to use ->
Code:
long lVal = pudtSR->udtValue1.lngValue;
 
thanks - i'd used -> previously but had got other compile errors that i's thought were connected to this.

doh ! thanks for the reply though - most other news groups have advised me to get another job !!!

Programming 101 I know but everyone makes mistakes ;-)
 
First rule of fixing compile errors:

Fix the first one. Recompile. Repeat as necessary.

Odds are, fixing the first one will automatically fix more errors! Ever leave the period off line 1 in a COBOL program? Which brings us to:

Second rule of fixing compile errors:

The real error is probably in the line above it or in the variable declaration.

Odds are, you left a period or a close quote or parenthesis off the line above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top