reading a structure

C

Charles Arnett

I want to know if this routine is correct.
I am reading a structure which starts with probeArray[0].rtp and has floats
and strings. I want to do a block write to a e^2 Prom frm the structure
located in ram.
Am I using pointers properly?

int probeDataWrite (void)
{
int startProbeAdd;
int writeStatus;

startProbeAdd = &probeArray[0].rpt;

writeStatus = 1;
for (i=0;i<192;i++){
writeStatus = ee_wr(0x20+i,*(startProbeAdd+1));
if (writeStatus !=0) return = 1;
}
}
charles arnett
(e-mail address removed)
 
T

Thomas J. Gritzan

Charles said:
I want to know if this routine is correct.
I am reading a structure which starts with probeArray[0].rtp and has floats
and strings. I want to do a block write to a e^2 Prom frm the structure
located in ram.
Am I using pointers properly?

I don't see any pointers here.
int probeDataWrite (void)
{
int startProbeAdd;
int writeStatus;

startProbeAdd = &probeArray[0].rpt;

You assign the address of something we don't know to an int. That won't
compile.
writeStatus = 1;

You don't need to assign here. Define your variables as late as
possible, and initialize them directly.
for (i=0;i<192;i++){

What's 192? You should avoid magic numbers.
writeStatus = ee_wr(0x20+i,*(startProbeAdd+1));

*(startProbeAdd+1) is the same as startProbeAdd[1]. Use the latter,
since every C++ programmer knows it and expects it.

May I guess that you wanted to write startProbeAdd instead?
if (writeStatus !=0) return = 1;

return = 1 won't compile.

You forgot a return statement at the end of the function, too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top