Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. I check, compile and run every program. Contact me at: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


6,846 questions

9,748 answers

573 users

How initialize part of array with the same number in C

1 Answer

0 votes
#include <stdio.h>

int main(void) 
{
   int array[] = { [3 ... 8] = 98};
   
   for (int i = 0; i < 9; i++)
   { 
        printf("array[%d] = %d\n", i, array[i]);
   }
  
   return 0;
}
    
/*
run:
 
array[0] = 0
array[1] = 0
array[2] = 0
array[3] = 98
array[4] = 98
array[5] = 98
array[6] = 98
array[7] = 98
array[8] = 98

*/

 




answered Aug 27, 2017 by avibootz
...