Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Indexing using #define

Status
Not open for further replies.

akshaybhavsar

Full Member level 2
Full Member level 2
Joined
May 5, 2016
Messages
135
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
898
Hello,

I have to extract packet information which is stored i array.I have to extract each byte.
I have to set index for each byte like

#define byte1 1
#define byte2 2

I have almost 70 bytes in packet.I cant do it 70 times.

I have to do somethning if possible'

#define byte_x (_x)

Please tell me any other way.
 

If you want to read the array from beginning to end in sequence then why do you use a variable like

Code:
unsigned int i = 0;

to use as array index ?
 

const char value[] = { 1, 2, 3, 4, 5... n }; -> array of char stored in flash
const char * names[] = { "James", "Peter", "Kumar ukurich" ... };
 

I have to extract each byte.
I have to set index for each byte

Unless each byte represents a distinc parameter, there is no other tricky way to do that; otherwise, if the whole array is only one datum, you just need to know the lenght of the array. Its address you can get straight with C statements, as for example the '&', and you can handle the index by incrementing an offset added to it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top