0

In C, I'm trying to initialise a structure's member but I'm unable to do it. Here is my code construct:

struct values{
  int a;
  int b;
  int b;
  int d;
 };
struct values value[65535]; 

I want to initialise b member of the structure to -1 for all the values in the struct object array. I'm unable to figure out good way to do this.

rampuriyaaa
  • 4,926
  • 10
  • 34
  • 41

2 Answers2

0

How about:

for (i = 0; i < 65535; i++)
    value[i].b = -1;
ad absurdum
  • 19,498
  • 5
  • 37
  • 60
0
#include<stdio.h>
struct values{
  int a;
  int b=-1;
  int c;
  int d;
 };
struct values value[65535];
int main(){
    printf("%d",value[2].b);
    return 0;
} 

Tell me if this helps.

red5pider
  • 351
  • 1
  • 9
  • 24