problems/risks due to programming language, stories requ

Charles Hannum CMH117 at psuvm.psu.edu
Fri Mar 16 11:47:00 AEST 1990


In article <1306 at mindlink.UUCP>, a563 at mindlink.UUCP (Dave Kirsch) says:
>
>switch (i) {
>  case 2 :  /* Add 2 to j */
>    j++;
>  case 1 :  /* Add 1 to j */
>    j++;
>  case 0 :  /* Print j out */
>    printf("%d\n", j);
>    break;
>  default :
>    printf("Illegal value in switch.\n");
>    abort();
>}

Why not this:

  if (i>2)
  {
      printf("Illegal value (dumbo!)\n");
      abort();
  }
  else printf("%d\n",j+=i);

Looks a little simpler to me ...


Virtually,
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117 at psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h at psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."



More information about the Comp.lang.c mailing list