Example 19

Fix the compile-time errors in Example 19 and run it. There is a serious problem here! What is it?
  /* This programme is meant to find the sum of two arrays/vectors and 
     print it out. */

  #include <stdio.h>

  int vecA[4] = {1,2,3,4}, vecB[4] = {90,91,92,93};

  int *vecadd(int *a1, a2) {
      int i, sum[4] ;

      for (i = 0; i < 4; i++)
          sum[i] = a1[i] + a1[i];

      return *sum;
    }

  main() { 
      int ans[4];

      ans = vecadd(vecA,vecB);

      int i;

      for (i=1; i < 4; i++)
          printf("%d \n",ans[i]);
    }


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_crash_in_c/_reml_grp/practical_c.reml_lib
On: 3/3/2003 at 16:27:16
Options: reml2 -i noindex -l long -o html -p multiple