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,656
  • 9
  • 32
  • 41

2 Answers2

0

How about:

for (i = 0; i < 65535; i++)
    value[i].b = -1;
ad absurdum
  • 17,836
  • 5
  • 33
  • 54
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.

Samar Yadav
  • 311
  • 1
  • 8
  • 22