Mega Code Archive

 
Categories / C / Code Snippets
 

Array initialization

#include <stdio.h> int array[] = {4, 2, 2, 3, 8, 4, 7, 2, 1, 3}; int index; int main() { index = 0; while (array[index] != 0) ++index; printf("Number of elements before zero %d\n", index); return (0); }