C Structure initialization (Array of integers and an integer value) -


#define max 10 struct setarray {     int item[max];     int count; }; typedef struct setarray *bitset; 

how should initialize elements in structure?

for example

struct setarray s = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, max }; 

or

struct setarray s;  ( int = 0; < max; i++ ) s.item[i] = i; s.count = max; 

or

bitset p = malloc( sizeof( *p ) );  ( int = 0; < max; i++ ) p->item[i] = i; p->count = max; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -