News for hackers. Stuff that matters.
Re:Git's list of banned C functions by fho on Friday March 05, 2021 @02:35AM (#26353926)
Question: how do you teach for-loops?

That is something I have a hard time convey as a teacher. My problem is that I have done this so long that I have no idea what there is not to understand about loops ... it's such a simple thing. But my (undergrad biology) students regularly have a hard time groking the concept no matter what explanation I use.

Re:Git's list of banned C functions by dave84 on Friday March 05, 2021 @05:49AM (#26355366)
Not OP but I'm teaching undergrad C. I'm assuming you have covered while loops before hand, if not, start there and cover the constructs with them that you would normally use a for loop for, example:

  int i = 0; //a
   
  while(i < 10) //b
  {
      printf("%d\n"); //c
      ++i; //d
  }
and introduce for loops as a special case of the while loop:

      //a        //b     //d
  for(int i = 0; i < 10; ++i)
  {
      printf("%d\n",i); //c
  }
Then outline situations when you would use a for loop over a while loop, fixed number of repetitions, use with arrays etc.
Re:Git's list of banned C functions by InvOfSmallC on Saturday March 06, 2021 @04:51AM (#26366360)
Well I took the time and made some simple animation of how that works. For that and pointers I use animation so they can visualize what's happening. (Wasn't my idea, I googled it "how to explain pointers")