fork(15) download
  1. #include <stdio.h>
  2.  
  3. #define MAXN 1000
  4.  
  5. int N = 0;
  6. int a[MAXN];
  7.  
  8. int main(void) {
  9. int tmp;
  10. while( scanf( "%d", &tmp) != EOF ) {
  11. a[N++] = tmp;
  12. }
  13. // reading is done, array lenght is in N, elements 0..N-1 are set in a array
  14. printf("N=%d\n", N);
  15. int i;
  16. for ( i = 0; i < N; ++i ) {
  17. printf( "a[%d]=%d\n", i, a[i]);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 2300KB
stdin
10
15
20 25 30
stdout
N=5
a[0]=10
a[1]=15
a[2]=20
a[3]=25
a[4]=30