| | |
Array of structures
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 10
Reputation:
Solved Threads: 0
Hi, I have a structure in a library that defines various parameters for wireless transmission. I want to create an array of these structures, which each element in the array containing the required parameters for a particular wireless channel.
The structure:
My attempt at defining the array is as follows:
It has been a while since i have done any C programming, an i cant seem to find a good example of what i am trying to do. Any help would be greatly appreciated.
The structure:
C Syntax (Toggle Plain Text)
typedef struct S_RF_RXTXPAIR_SETTINGS { byte modem0; // Baudrate, xosc_freq, dataformat byte modem1; // settling, peakdetect byte modem2; // Peak level offset byte freq_2a; // RX channel frequency (A) byte freq_1a; byte freq_0a; byte freq_2b; // TX channel frequency (B) byte freq_1b; byte freq_0b; byte fsep1; // Frequency seperation byte fsep0; byte pll_rx; // refdiv byte pll_tx; // refdiv byte current_rx; // vco_current, lo_drive, pa_drive byte current_tx; // vco_current, lo_drive, pa_drive byte frend; // buf_current, lna_current byte pa_pow; // TX output power byte match; // rx_match, tx_match byte prescaler; // pre_swing, pre_current } RF_RXTXPAIR_SETTINGS;
My attempt at defining the array is as follows:
C Syntax (Toggle Plain Text)
RF_RXTXPAIR_SETTINGS code RF_SETTINGS[2]; RF_SETTINGS[1] = {0xA8,0x2F,0x37,0x50,0xA0,0x00,0x41,0xF6,0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A,0xFF,0xC0,0x00}; RF_SETTINGS[2] = {0xA8,0x2F,0x37,0x50,0xA8,0x00,0x41,0xF6,0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A,0xFF,0xC0,0x00};
It has been a while since i have done any C programming, an i cant seem to find a good example of what i am trying to do. Any help would be greatly appreciated.
Well the first thing you need to remember is arrays start at 0, not 1.
2. Arrays can be initialised, not assigned, eg
2. Arrays can be initialised, not assigned, eg
C Syntax (Toggle Plain Text)
RF_RXTXPAIR_SETTINGS RF_SETTINGS[2] = { {0xA8,0x2F,0x37,0x50,0xA0,0x00,0x41,0xF6, 0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A, 0xFF,0xC0,0x00}, {0xA8,0x2F,0x37,0x50,0xA8,0x00,0x41,0xF6, 0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A, 0xFF,0xC0,0x00} };
![]() |
Similar Threads
- Need help with array of structures (C++)
- Dynamic array of structures (C++)
- Error with array structures :( (C++)
- array of structures within a struct (C++)
- Dynamic Array of Structures, Loop problem! (C++)
- Creating dynamic array structures (C++)
- Passing array of structures into a function (C++)
- dynamic array of structures problem (C++)
Other Threads in the C Forum
- Previous Thread: Legal & use in C
- Next Thread: serial port access
Views: 1465 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createprocess() database directory drawing dynamic execv feet fgets file floatingpointvalidation fork framework function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes read recursion recv recvblocked reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi






