473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Reading contents of a structure

3
Please help:

I want to read out all the bytes of a structure and to write these to EEPROM i.e map the memory locations of the structure to EEPROM.

Can one use a pointer and increment it to point at each byte in a structure? I know how to do this using a pointer to an array, but not a pointer to a structure.

Need something along the lines of :

void TestRoutine (void)
{
struct Calib // Structure to hold calibration data
{
signed int DcOffset[3];
signed int CorrFctr[2][3][3];
} CalData;

unsigned int i;
struct Calib *st_ptr;

st_ptr = &CalData;

for (i=0; i <= SizeOfStructure, i++) do
{
printf("Value at this address is: %d \n", *st_ptr); // write contents at address pointed to by pointer
st_ptr++; // point to next byte in structure and repeat
}



I know something like

for (i = 0; i <= 3; i++)
printf("Value at this address is: %d \n",st_ptr->DcOffset[i]);

will work, but seems to me there should be a way to read each byte from the structure Calib without having to reference its members such as DcOffset ?

Thanks.
Nov 3 '06 #1
0 1056

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve_EE | last post by:
I'm running phpMyAdmin 2.5.3 / MySQL 4.0.14 / PHP 4.3.3 / Apache 1.3.20 phpMyAdmin is installed and appears ok at first, I can login, select databases, view which tables are in each db, see the...
6
by: David Gray | last post by:
Greetings all, I'm working on a program that allows a user to enter notes in a multiline textbox. I would like to be able to read the contents of the textbox (as records - one per line) and...
3
by: markspace | last post by:
Hi all, Here's a question I haven't been able to answer on my own. I want to read in the entire contents of a file into some structure in memory then process it. Like for example read an image...
3
by: Zahid | last post by:
Hi, I have declared an array holding a custom declared structure. The structure looks like this: Private Structure MnuDataFrmFile Public menuGroup As String Public ItemDesc As String Public...
3
by: Zeke Zinzul | last post by:
Hi Guys & Geeks, What's the most elegant way of dealing with binary data and structures? Say I have this (which I actually do, a woo-hoo): struct Struct_IconHeader { byte width; byte...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
10
by: =?Utf-8?B?TmFuZCBLaXNob3JlIEd1cHRh?= | last post by:
I have a binary file created using C++ that contains an object of the structure: struct student { int roll_no; char name; char qualification; };
16
by: Jm.GlezdeRueda | last post by:
Hi all, Im trying to read a 24bit bmp with fread, and i have some problems.. I want to read the whole structure in one time, but i dont know why, it only reads the first member well.. I have...
0
Guido Geurs
by: Guido Geurs | last post by:
I'm writing a program that list the contents of a CDrom and also the contents of the ZIP files. When there is a bad Zip file on the CD, the program keeps traying to reed the file and after +- 50...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.